From 4ea763124bbdc59d8250173dff4fc91ff131ee4c Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 31 Oct 2024 16:34:00 +0100 Subject: [PATCH] fixed undelete view for SQL server --- integration-tests/engines.js | 4 ++-- packages/tools/src/diffTools.ts | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/integration-tests/engines.js b/integration-tests/engines.js index eb14d8c4..011af637 100644 --- a/integration-tests/engines.js +++ b/integration-tests/engines.js @@ -188,8 +188,8 @@ const filterLocal = [ // filter local testing '-MySQL', '-MariaDB', - 'PostgreSQL', - '-SQL Server', + '-PostgreSQL', + 'SQL Server', '-SQLite', '-CockroachDB', '-ClickHouse', diff --git a/packages/tools/src/diffTools.ts b/packages/tools/src/diffTools.ts index 8e6222a3..ecccef9e 100644 --- a/packages/tools/src/diffTools.ts +++ b/packages/tools/src/diffTools.ts @@ -647,10 +647,19 @@ export function createAlterDatabasePlan( } else if (!opts.noDropSqlObject) { plan.dropSqlObject(oldobj); } - } else if (!testEqualSqlObjects(oldobj, newobj, opts)) { - plan.recreates.sqlObjects += 1; - plan.dropSqlObject(oldobj); - plan.createSqlObject(newobj); + } else { + if ( + opts.deletedSqlObjectPrefix && + driver.dialect.renameSqlObject && + hasDeletedPrefix(oldobj.pureName, opts, opts.deletedSqlObjectPrefix) + ) { + plan.dropSqlObject(oldobj); + plan.createSqlObject(newobj); + } else if (!testEqualSqlObjects(oldobj, newobj, opts)) { + plan.recreates.sqlObjects += 1; + plan.dropSqlObject(oldobj); + plan.createSqlObject(newobj); + } } } }