mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-02 05:33:59 +00:00
allowTableMarkDropped WIP
This commit is contained in:
@@ -9,6 +9,7 @@ async function deployDb({
|
||||
modelFolder,
|
||||
loadedDbModel,
|
||||
modelTransforms,
|
||||
dbdiffOptionsExtra,
|
||||
}) {
|
||||
const { sql } = await generateDeploySql({
|
||||
connection,
|
||||
@@ -18,6 +19,7 @@ async function deployDb({
|
||||
modelFolder,
|
||||
loadedDbModel,
|
||||
modelTransforms,
|
||||
dbdiffOptionsExtra,
|
||||
});
|
||||
// console.log('RUNNING DEPLOY SCRIPT:', sql);
|
||||
await executeQuery({ connection, systemConnection, driver, sql, logScriptItems: true });
|
||||
|
||||
@@ -19,6 +19,7 @@ async function generateDeploySql({
|
||||
modelFolder = undefined,
|
||||
loadedDbModel = undefined,
|
||||
modelTransforms = undefined,
|
||||
dbdiffOptionsExtra = {},
|
||||
}) {
|
||||
if (!driver) driver = requireEngineDriver(connection);
|
||||
|
||||
@@ -48,6 +49,8 @@ async function generateDeploySql({
|
||||
noDropSqlObject: true,
|
||||
noRenameTable: true,
|
||||
noRenameColumn: true,
|
||||
|
||||
...dbdiffOptionsExtra,
|
||||
};
|
||||
const currentModelPaired = matchPairedObjects(deployedModel, currentModel, opts);
|
||||
const currentModelPairedPreloaded = await enrichWithPreloadedRows(deployedModel, currentModelPaired, dbhan, driver);
|
||||
|
||||
@@ -441,7 +441,7 @@ export class AlterPlan {
|
||||
// console.log('*****************RECREATED NEEDED', op, operationType, isAllowed);
|
||||
// console.log(this.dialect);
|
||||
|
||||
if (this.opts.noDropTable) {
|
||||
if (this.opts.noDropTable && !this.opts.allowTableRecreateWhenNoDrop) {
|
||||
// skip this operation, as it cannot be achieved
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -35,9 +35,17 @@ export interface DbDiffOptions {
|
||||
ignoreConstraintNames?: boolean;
|
||||
|
||||
noDropTable?: boolean;
|
||||
allowTableRecreateWhenNoDrop?: boolean;
|
||||
allowTableMarkDropped?: boolean;
|
||||
|
||||
noDropColumn?: boolean;
|
||||
allowColumnMarkDropped?: boolean;
|
||||
|
||||
noDropConstraint?: boolean;
|
||||
|
||||
noDropSqlObject?: boolean;
|
||||
allowSqlObjectMarkDropped?: boolean;
|
||||
|
||||
noRenameTable?: boolean;
|
||||
noRenameColumn?: boolean;
|
||||
|
||||
@@ -565,7 +573,9 @@ export function createAlterDatabasePlan(
|
||||
const newobj = (newDb[objectTypeField] || []).find(x => x.pairingId == oldobj.pairingId);
|
||||
if (objectTypeField == 'tables') {
|
||||
if (newobj == null) {
|
||||
if (!opts.noDropTable) {
|
||||
if (opts.allowTableMarkDropped) {
|
||||
plan.renameTable(oldobj, '_deleted_' + oldobj.pureName);
|
||||
} else if (!opts.noDropTable) {
|
||||
plan.dropTable(oldobj);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user