mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 01:46:01 +00:00
alter table fixed
This commit is contained in:
@@ -523,6 +523,54 @@ export class AlterPlan {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_removeRecreatedTableAlters(): AlterOperation[] {
|
||||||
|
const res: AlterOperation[] = [];
|
||||||
|
const recreates = new Set<string>();
|
||||||
|
for (const op of this.operations) {
|
||||||
|
if (op.operationType == 'recreateTable' && op.oldTable && op.newTable) {
|
||||||
|
const key = `${op.oldTable.schemaName}||${op.oldTable.pureName}`;
|
||||||
|
recreates.add(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const op of this.operations) {
|
||||||
|
switch (op.operationType) {
|
||||||
|
case 'createColumn':
|
||||||
|
case 'createConstraint':
|
||||||
|
{
|
||||||
|
const key = `${op.newObject.schemaName}||${op.newObject.pureName}`;
|
||||||
|
if (recreates.has(key)) {
|
||||||
|
// skip create inside recreated table
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'dropColumn':
|
||||||
|
case 'dropConstraint':
|
||||||
|
case 'changeColumn':
|
||||||
|
{
|
||||||
|
const key = `${op.oldObject.schemaName}||${op.oldObject.pureName}`;
|
||||||
|
if (recreates.has(key)) {
|
||||||
|
// skip drop/change inside recreated table
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'renameColumn':
|
||||||
|
{
|
||||||
|
const key = `${op.object.schemaName}||${op.object.pureName}`;
|
||||||
|
if (recreates.has(key)) {
|
||||||
|
// skip rename inside recreated table
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
res.push(op);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
_groupTableRecreations(): AlterOperation[] {
|
_groupTableRecreations(): AlterOperation[] {
|
||||||
const res = [];
|
const res = [];
|
||||||
const recreates = new Set<string>();
|
const recreates = new Set<string>();
|
||||||
@@ -637,6 +685,8 @@ export class AlterPlan {
|
|||||||
|
|
||||||
// console.log('*****************OPERATIONS3', this.operations);
|
// console.log('*****************OPERATIONS3', this.operations);
|
||||||
|
|
||||||
|
this.operations = this._removeRecreatedTableAlters();
|
||||||
|
|
||||||
this.operations = this._moveForeignKeysToLast();
|
this.operations = this._moveForeignKeysToLast();
|
||||||
|
|
||||||
// console.log('*****************OPERATIONS4', this.operations);
|
// console.log('*****************OPERATIONS4', this.operations);
|
||||||
|
|||||||
Reference in New Issue
Block a user