Merge branch 'master' into feature/1137-mssql-column-desc

This commit is contained in:
Pavel
2025-08-07 12:53:09 +02:00
102 changed files with 1333 additions and 341 deletions

View File

@@ -130,26 +130,25 @@ class MsSqlAnalyser extends DatabaseAnalyser {
}
async _runAnalysis() {
this.feedback({ analysingMessage: 'Loading tables' });
this.feedback({ analysingMessage: 'DBGM-00205 Loading tables' });
const tablesRows = await this.analyserQuery('tables', ['tables']);
this.feedback({ analysingMessage: 'Loading columns' });
this.feedback({ analysingMessage: 'DBGM-00206 Loading columns' });
const columnsRows = await this.analyserQuery('columns', ['tables']);
const columns = columnsRows.rows.map(getColumnInfo);
this.feedback({ analysingMessage: 'Loading primary keys' });
this.feedback({ analysingMessage: 'DBGM-00207 Loading primary keys' });
const pkColumnsRows = await this.analyserQuery('primaryKeys', ['tables']);
this.feedback({ analysingMessage: 'Loading foreign keys' });
this.feedback({ analysingMessage: 'DBGM-00208 Loading foreign keys' });
const fkColumnsRows = await this.analyserQuery('foreignKeys', ['tables']);
this.feedback({ analysingMessage: 'Loading indexes' });
this.feedback({ analysingMessage: 'DBGM-00209 Loading indexes' });
const indexesRows = await this.analyserQuery('indexes', ['tables']);
this.feedback({ analysingMessage: 'Loading index columns' });
this.feedback({ analysingMessage: 'DBGM-00210 Loading index columns' });
const indexcolsRows = await this.analyserQuery('indexcols', ['tables']);
this.feedback({ analysingMessage: 'Loading table sizes' });
this.feedback({ analysingMessage: 'DBGM-00211 Loading table sizes' });
const tableSizes = await this.analyserQuery('tableSizes');
const tableSizesDict = _.mapValues(_.keyBy(tableSizes.rows, 'objectId'), 'tableRowCount');
this.feedback({ analysingMessage: 'Loading SQL code' });
this.feedback({ analysingMessage: 'DBGM-00212 Loading SQL code' });
const sqlCodeRows = await this.analyserQuery('loadSqlCode', ['views', 'procedures', 'functions', 'triggers']);
const getCreateSql = row =>
sqlCodeRows.rows
@@ -157,21 +156,21 @@ class MsSqlAnalyser extends DatabaseAnalyser {
.map(x => x.codeText)
.join('');
this.feedback({ analysingMessage: 'Loading views' });
this.feedback({ analysingMessage: 'DBGM-00213 Loading views' });
const viewsRows = await this.analyserQuery('views', ['views']);
this.feedback({ analysingMessage: 'Loading procedures & functions' });
this.feedback({ analysingMessage: 'DBGM-00214 Loading procedures & functions' });
const programmableRows = await this.analyserQuery('programmables', ['procedures', 'functions']);
const procedureParameterRows = await this.analyserQuery('proceduresParameters');
const functionParameterRows = await this.analyserQuery('functionParameters');
this.feedback({ analysingMessage: 'Loading triggers' });
this.feedback({ analysingMessage: 'DBGM-00215 Loading triggers' });
const triggerRows = await this.analyserQuery('triggers');
this.feedback({ analysingMessage: 'Loading view columns' });
this.feedback({ analysingMessage: 'DBGM-00216 Loading view columns' });
const viewColumnRows = await this.analyserQuery('viewColumns', ['views']);
this.feedback({ analysingMessage: 'Finalizing DB structure' });
this.feedback({ analysingMessage: 'DBGM-00217 Finalizing DB structure' });
const tables = tablesRows.rows.map(row => ({
...row,
contentHash: createObjectContentHash('tables', row, columns),
@@ -273,8 +272,8 @@ class MsSqlAnalyser extends DatabaseAnalyser {
async _getFastSnapshot() {
const modificationsQueryData = await this.analyserQuery('modifications');
const baseColumnsRows = await this.analyserQuery('columns', ['tables']);
const baseColumns = baseColumnsRows.rows.map(getColumnInfo);
const baseColumnsRows = await this.analyserQuery('baseColumns', ['tables']);
const baseColumns = baseColumnsRows.rows;
const tableSizes = await this.analyserQuery('tableSizes');
const res = DatabaseAnalyser.createEmptyStructure();

View File

@@ -72,7 +72,7 @@ function createTediousBulkInsertStream(driver, stream, dbhan, name, options) {
try {
await runBulkInsertBatch(dbhan, fullName, writable, rows);
} catch (err) {
logger.error(extractErrorLogData(err), 'Error during bulk insert, insert stopped');
logger.error(extractErrorLogData(err), 'DBGM-00199 Error during bulk insert, insert stopped');
// writable.emit('error', err);
writable.destroy(err);
}

View File

@@ -96,6 +96,7 @@ const driver = {
client,
connectionType,
database: conn.database,
conid: conn.conid,
};
},
async close(dbhan) {
@@ -169,7 +170,7 @@ const driver = {
const defaultSchemaRows = await this.query(dbhan, 'SELECT SCHEMA_NAME() as name');
const defaultSchema = defaultSchemaRows.rows[0]?.name;
logger.debug(`Loaded ${rows.length} mssql schemas`);
logger.debug(`DBGM-00140 Loaded ${rows.length} mssql schemas`);
return rows.map(x => ({
...x,