From 02aa94afc9575f0ad4f671e99f45d2bbf6f8c601 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 16 Sep 2021 11:05:43 +0200 Subject: [PATCH] sqlite incremental analysis recognizes indexes --- plugins/dbgate-plugin-sqlite/src/backend/Analyser.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js b/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js index f1c6deed..77b0d722 100644 --- a/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js +++ b/plugins/dbgate-plugin-sqlite/src/backend/Analyser.js @@ -12,7 +12,7 @@ SELECT pragma_index_list(m.name) AS il, pragma_index_info(il.name) AS ii WHERE m.type='table' AND il.origin <> 'pk' - ORDER BY ii.seqno + ORDER BY ii.seqno, il.name `; class Analyser extends DatabaseAnalyser { @@ -22,6 +22,7 @@ class Analyser extends DatabaseAnalyser { async _getFastSnapshot() { const objects = await this.driver.query(this.pool, "select * from sqlite_master where type='table' or type='view'"); + const indexcols = await this.driver.query(this.pool, indexcolsQuery); return { tables: objects.rows @@ -29,7 +30,12 @@ class Analyser extends DatabaseAnalyser { .map((x) => ({ pureName: x.name, objectId: x.name, - contentHash: x.sql, + contentHash: [ + x.sql, + ...indexcols.rows + .filter((y) => y.tableName == x.name) + .map((y) => `-- ${y.constraintName}: ${y.columnName}`), + ].join(';\n'), })), views: objects.rows .filter((x) => x.type == 'view')