mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 23:06:00 +00:00
maxMissingTablesRatio parameter
This commit is contained in:
@@ -17,6 +17,7 @@ async function deployDb({
|
||||
dbdiffOptionsExtra,
|
||||
ignoreNameRegex = '',
|
||||
targetSchema = null,
|
||||
maxMissingTablesRatio = undefined,
|
||||
}) {
|
||||
if (!driver) driver = requireEngineDriver(connection);
|
||||
const dbhan = systemConnection || (await connectUtility(driver, connection, 'read'));
|
||||
@@ -41,6 +42,7 @@ async function deployDb({
|
||||
dbdiffOptionsExtra,
|
||||
ignoreNameRegex,
|
||||
targetSchema,
|
||||
maxMissingTablesRatio,
|
||||
});
|
||||
// console.log('RUNNING DEPLOY SCRIPT:', sql);
|
||||
await executeQuery({ connection, systemConnection: dbhan, driver, sql, logScriptItems: true });
|
||||
|
||||
@@ -26,6 +26,7 @@ async function generateDeploySql({
|
||||
dbdiffOptionsExtra = {},
|
||||
ignoreNameRegex = '',
|
||||
targetSchema = null,
|
||||
maxMissingTablesRatio = undefined,
|
||||
}) {
|
||||
if (!driver) driver = requireEngineDriver(connection);
|
||||
|
||||
@@ -80,6 +81,17 @@ async function generateDeploySql({
|
||||
const currentModelPaired = matchPairedObjects(deployedModel, currentModel, opts);
|
||||
const currentModelPairedPreloaded = await enrichWithPreloadedRows(deployedModel, currentModelPaired, dbhan, driver);
|
||||
|
||||
if (maxMissingTablesRatio != null) {
|
||||
const missingTables = currentModelPaired.tables.filter(
|
||||
x => !deployedModel.tables.find(y => y.pairingId == x.pairingId)
|
||||
);
|
||||
const missingTableCount = missingTables.length;
|
||||
const missingTablesRatio = missingTableCount / (currentModelPaired.tables.length || 1);
|
||||
if (missingTablesRatio > maxMissingTablesRatio) {
|
||||
throw new Error(`Too many missing tables (${missingTablesRatio * 100}%), aborting deploy`);
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('currentModelPairedPreloaded', currentModelPairedPreloaded.tables[0]);
|
||||
// console.log('deployedModel', deployedModel.tables[0]);
|
||||
// console.log('currentModel', currentModel.tables[0]);
|
||||
|
||||
Reference in New Issue
Block a user