AppDbUpdater: Actually check foreign key violations after updating

This commit is contained in:
2024-02-29 02:03:41 +01:00
parent 546a9f23c1
commit d897e44f3b
3 changed files with 23 additions and 1 deletions

View File

@ -79,8 +79,13 @@ namespace Elwig.Helpers {
foreach (var script in toExecute) {
await AppDbContext.ExecuteEmbeddedScript(cnx, asm, script);
}
var violations = await AppDbContext.ForeignKeyCheck(cnx);
if (violations.Length > 0) {
throw new Exception($"Foreign key violations ({violations.Length}):\n" + string.Join("\n", violations
.Select(v => $"{v.Table} - {v.RowId} - {v.Parent} - {v.FkId}")));
}
await AppDbContext.ExecuteBatch(cnx, $"""
PRAGMA foreign_key_check;
COMMIT;
PRAGMA foreign_keys = ON;
VACUUM;