Skip to content

Commit 4e807df

Browse files
vgrozdanicclaude
andcommitted
fix(migrations): Skip pg_dumpall restrict/unrestrict tokens in drift check
PostgreSQL 16+ emits \restrict and \unrestrict directives with random per-session tokens in pg_dumpall output. These tokens differ between any two dumps and are unrelated to the database schema, causing the migration drift detection to always report false positives. Filter out these lines in the norm() function alongside the existing filters for comments and django_migrations tables. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
1 parent db8e93c commit 4e807df

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/migrations/compare.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def norm(s: str) -> dict[str, str]:
3939
_, db = line.split()
4040
if line.startswith("--"):
4141
continue
42+
# pg_dumpall (PostgreSQL 16+) emits \restrict / \unrestrict with
43+
# random per-session tokens. These are not part of the schema.
44+
if line.startswith(r"\restrict ") or line.startswith(r"\unrestrict "):
45+
continue
4246
if last == "\n" and line == "\n":
4347
continue
4448
else:

0 commit comments

Comments
 (0)