Skip to content

Commit 554290f

Browse files
authored
Revert "Use PRAGMA defer_foreign_keys instead of PRAGMA foreign_keys when…" (#38120)
This reverts commit 89b2687.
1 parent 6151954 commit 554290f

3 files changed

Lines changed: 269 additions & 55 deletions

File tree

src/EFCore.Sqlite.Core/Migrations/SqliteMigrationsSqlGenerator.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ private IReadOnlyList<MigrationOperation> RewriteOperations(
458458
if (rebuilds.Any())
459459
{
460460
operations.Add(
461-
new SqlOperation { Sql = "PRAGMA defer_foreign_keys = 1;" });
461+
new SqlOperation { Sql = "PRAGMA foreign_keys = 0;", SuppressTransaction = true });
462462
}
463463

464464
foreach (var ((table, schema), _) in rebuilds)
@@ -475,6 +475,12 @@ private IReadOnlyList<MigrationOperation> RewriteOperations(
475475
});
476476
}
477477

478+
if (rebuilds.Any())
479+
{
480+
operations.Add(
481+
new SqlOperation { Sql = "PRAGMA foreign_keys = 1;", SuppressTransaction = true });
482+
}
483+
478484
foreach (var index in indexesToRebuild)
479485
{
480486
operations.Add(CreateIndexOperation.CreateFrom(index));

0 commit comments

Comments
 (0)