diff --git a/packages/tools/src/alterPlan.ts b/packages/tools/src/alterPlan.ts index a609042fa..8002739b5 100644 --- a/packages/tools/src/alterPlan.ts +++ b/packages/tools/src/alterPlan.ts @@ -524,9 +524,22 @@ export class AlterPlan { } _groupTableRecreations(): AlterOperation[] { - return this.operations; + const res = []; + const recreates = new Set(); + for (const op of this.operations) { + if (op.operationType == 'recreateTable' && op.oldTable && op.newTable) { + const key = `${op.oldTable.schemaName}||${op.oldTable.pureName}`; + if (recreates.has(key)) { + // prevent duplicate recreates + continue; + } + recreates.add(key); + } + + res.push(op); + } + return res; - // this is not implemented now // const res = []; // const recreates = {}; // for (const op of this.operations) {