db alter plan improvements

This commit is contained in:
SPRINX0\prochazka
2024-11-11 11:07:57 +01:00
parent a069093f6b
commit 75b4f49e31
14 changed files with 64 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ async function deployDb({
modelTransforms,
dbdiffOptionsExtra,
ignoreNameRegex = '',
targetSchema = null,
}) {
const { sql } = await generateDeploySql({
connection,
@@ -22,6 +23,7 @@ async function deployDb({
modelTransforms,
dbdiffOptionsExtra,
ignoreNameRegex,
targetSchema,
});
// console.log('RUNNING DEPLOY SCRIPT:', sql);
await executeQuery({ connection, systemConnection, driver, sql, logScriptItems: true });

View File

@@ -7,6 +7,8 @@ const {
modelCompareDbDiffOptions,
enrichWithPreloadedRows,
skipNamesInStructureByRegex,
replaceSchemaInStructure,
filterStructureBySchema,
} = require('dbgate-tools');
const importDbModel = require('../utility/importDbModel');
const requireEngineDriver = require('../utility/requireEngineDriver');
@@ -22,6 +24,7 @@ async function generateDeploySql({
modelTransforms = undefined,
dbdiffOptionsExtra = {},
ignoreNameRegex = '',
targetSchema = null,
}) {
if (!driver) driver = requireEngineDriver(connection);
@@ -44,6 +47,11 @@ async function generateDeploySql({
deployedModelSource = transform(deployedModelSource);
}
if (targetSchema) {
deployedModelSource = replaceSchemaInStructure(deployedModelSource, targetSchema);
analysedStructure = filterStructureBySchema(analysedStructure, targetSchema);
}
const deployedModel = generateDbPairingId(extendDatabaseInfo(deployedModelSource));
const currentModel = generateDbPairingId(extendDatabaseInfo(analysedStructure));
const opts = {