mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 18:26:00 +00:00
recreate object warning
This commit is contained in:
@@ -104,6 +104,12 @@ type AlterOperation =
|
||||
| AlterOperation_RecreateTable;
|
||||
|
||||
export class AlterPlan {
|
||||
recreates = {
|
||||
tables: 0,
|
||||
constraints: 0,
|
||||
sqlObjects: 0,
|
||||
};
|
||||
|
||||
public operations: AlterOperation[] = [];
|
||||
constructor(public db: DatabaseInfo, public dialect: SqlDialect) {}
|
||||
|
||||
@@ -209,6 +215,7 @@ export class AlterPlan {
|
||||
table,
|
||||
operations,
|
||||
});
|
||||
this.recreates.tables += 1;
|
||||
}
|
||||
|
||||
run(processor: AlterProcessor) {
|
||||
@@ -270,6 +277,10 @@ export class AlterPlan {
|
||||
return opRes;
|
||||
}),
|
||||
];
|
||||
|
||||
if (constraints.length > 0) {
|
||||
this.recreates.constraints += 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -289,6 +300,7 @@ export class AlterPlan {
|
||||
}
|
||||
|
||||
if (op.operationType == 'changeConstraint') {
|
||||
this.recreates.constraints += 1;
|
||||
const opDrop: AlterOperation = {
|
||||
operationType: 'dropConstraint',
|
||||
oldObject: op.oldObject,
|
||||
@@ -356,6 +368,7 @@ export class AlterPlan {
|
||||
const table = this.db.tables.find(
|
||||
x => x.pureName == op[objectField].pureName && x.schemaName == op[objectField].schemaName
|
||||
);
|
||||
this.recreates.tables += 1;
|
||||
return [
|
||||
{
|
||||
operationType: 'recreateTable',
|
||||
|
||||
@@ -348,6 +348,7 @@ export function createAlterDatabasePlan(
|
||||
} else {
|
||||
if (newobj == null) plan.dropSqlObject(oldobj);
|
||||
else if (newobj.createSql != oldobj.createSql) {
|
||||
plan.recreates.sqlObjects += 1;
|
||||
plan.dropSqlObject(oldobj);
|
||||
plan.createSqlObject(newobj);
|
||||
}
|
||||
@@ -372,13 +373,16 @@ export function getAlterTableScript(
|
||||
opts: DbDiffOptions,
|
||||
db: DatabaseInfo,
|
||||
driver: EngineDriver
|
||||
): string {
|
||||
) {
|
||||
const plan = createAlterTablePlan(oldTable, newTable, opts, db, driver);
|
||||
const dmp = driver.createDumper();
|
||||
if (!driver.dialect.disableExplicitTransaction) dmp.beginTransaction();
|
||||
plan.run(dmp);
|
||||
if (!driver.dialect.disableExplicitTransaction) dmp.commitTransaction();
|
||||
return dmp.s;
|
||||
return {
|
||||
sql: dmp.s,
|
||||
recreates: plan.recreates,
|
||||
};
|
||||
}
|
||||
|
||||
export function getAlterDatabaseScript(
|
||||
@@ -387,11 +391,14 @@ export function getAlterDatabaseScript(
|
||||
opts: DbDiffOptions,
|
||||
db: DatabaseInfo,
|
||||
driver: EngineDriver
|
||||
): string {
|
||||
) {
|
||||
const plan = createAlterDatabasePlan(oldDb, newDb, opts, db, driver);
|
||||
const dmp = driver.createDumper();
|
||||
if (!driver.dialect.disableExplicitTransaction) dmp.beginTransaction();
|
||||
plan.run(dmp);
|
||||
if (!driver.dialect.disableExplicitTransaction) dmp.commitTransaction();
|
||||
return dmp.s;
|
||||
return {
|
||||
sql: dmp.s,
|
||||
recreates: plan.recreates,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user