mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 01:46:01 +00:00
mssql analyser feedback messages
This commit is contained in:
@@ -70,20 +70,30 @@ class MsSqlAnalyser extends DatabaseAnalyser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _runAnalysis() {
|
async _runAnalysis() {
|
||||||
|
this.feedback({ analysingMessage: 'Loading tables' });
|
||||||
const tablesRows = await this.driver.query(this.pool, this.createQuery('tables', ['tables']));
|
const tablesRows = await this.driver.query(this.pool, this.createQuery('tables', ['tables']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading columns' });
|
||||||
const columnsRows = await this.driver.query(this.pool, this.createQuery('columns', ['tables']));
|
const columnsRows = await this.driver.query(this.pool, this.createQuery('columns', ['tables']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading primary keys' });
|
||||||
const pkColumnsRows = await this.driver.query(this.pool, this.createQuery('primaryKeys', ['tables']));
|
const pkColumnsRows = await this.driver.query(this.pool, this.createQuery('primaryKeys', ['tables']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading foreign keys' });
|
||||||
const fkColumnsRows = await this.driver.query(this.pool, this.createQuery('foreignKeys', ['tables']));
|
const fkColumnsRows = await this.driver.query(this.pool, this.createQuery('foreignKeys', ['tables']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading schemas' });
|
||||||
const schemaRows = await this.driver.query(this.pool, this.createQuery('getSchemas'));
|
const schemaRows = await this.driver.query(this.pool, this.createQuery('getSchemas'));
|
||||||
|
this.feedback({ analysingMessage: 'Loading indexes' });
|
||||||
const indexesRows = await this.driver.query(this.pool, this.createQuery('indexes', ['tables']));
|
const indexesRows = await this.driver.query(this.pool, this.createQuery('indexes', ['tables']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading index columns' });
|
||||||
const indexcolsRows = await this.driver.query(this.pool, this.createQuery('indexcols', ['tables']));
|
const indexcolsRows = await this.driver.query(this.pool, this.createQuery('indexcols', ['tables']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading default schema' });
|
||||||
const defaultSchemaRows = await this.driver.query(this.pool, 'SELECT SCHEMA_NAME() as name');
|
const defaultSchemaRows = await this.driver.query(this.pool, 'SELECT SCHEMA_NAME() as name');
|
||||||
|
this.feedback({ analysingMessage: 'Loading table sizes' });
|
||||||
const tableSizes = await this.driver.query(this.pool, this.createQuery('tableSizes'));
|
const tableSizes = await this.driver.query(this.pool, this.createQuery('tableSizes'));
|
||||||
|
|
||||||
const schemas = schemaRows.rows;
|
const schemas = schemaRows.rows;
|
||||||
|
|
||||||
const tableSizesDict = _.mapValues(_.keyBy(tableSizes.rows, 'objectId'), 'tableRowCount');
|
const tableSizesDict = _.mapValues(_.keyBy(tableSizes.rows, 'objectId'), 'tableRowCount');
|
||||||
|
|
||||||
|
this.feedback({ analysingMessage: 'Loading SQL code' });
|
||||||
const sqlCodeRows = await this.driver.query(
|
const sqlCodeRows = await this.driver.query(
|
||||||
this.pool,
|
this.pool,
|
||||||
this.createQuery('loadSqlCode', ['views', 'procedures', 'functions', 'triggers'])
|
this.createQuery('loadSqlCode', ['views', 'procedures', 'functions', 'triggers'])
|
||||||
@@ -93,13 +103,18 @@ class MsSqlAnalyser extends DatabaseAnalyser {
|
|||||||
.filter(x => x.pureName == row.pureName && x.schemaName == row.schemaName)
|
.filter(x => x.pureName == row.pureName && x.schemaName == row.schemaName)
|
||||||
.map(x => x.codeText)
|
.map(x => x.codeText)
|
||||||
.join('');
|
.join('');
|
||||||
|
|
||||||
|
this.feedback({ analysingMessage: 'Loading views' });
|
||||||
const viewsRows = await this.driver.query(this.pool, this.createQuery('views', ['views']));
|
const viewsRows = await this.driver.query(this.pool, this.createQuery('views', ['views']));
|
||||||
|
this.feedback({ analysingMessage: 'Loading procedures & functions' });
|
||||||
const programmableRows = await this.driver.query(
|
const programmableRows = await this.driver.query(
|
||||||
this.pool,
|
this.pool,
|
||||||
this.createQuery('programmables', ['procedures', 'functions'])
|
this.createQuery('programmables', ['procedures', 'functions'])
|
||||||
);
|
);
|
||||||
|
this.feedback({ analysingMessage: 'Loading view columns' });
|
||||||
const viewColumnRows = await this.driver.query(this.pool, this.createQuery('viewColumns', ['views']));
|
const viewColumnRows = await this.driver.query(this.pool, this.createQuery('viewColumns', ['views']));
|
||||||
|
|
||||||
|
this.feedback({ analysingMessage: 'Finalizing DB structure' });
|
||||||
const tables = tablesRows.rows.map(row => ({
|
const tables = tablesRows.rows.map(row => ({
|
||||||
...row,
|
...row,
|
||||||
contentHash: row.modifyDate && row.modifyDate.toISOString(),
|
contentHash: row.modifyDate && row.modifyDate.toISOString(),
|
||||||
@@ -152,6 +167,7 @@ class MsSqlAnalyser extends DatabaseAnalyser {
|
|||||||
createSql: getCreateSql(row),
|
createSql: getCreateSql(row),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
this.feedback({ analysingMessage: null });
|
||||||
return {
|
return {
|
||||||
tables,
|
tables,
|
||||||
views,
|
views,
|
||||||
|
|||||||
Reference in New Issue
Block a user