Skip to content

Commit 6d3af9d

Browse files
vgrozdanicclaude
andauthored
fix(migrations): Skip pg_dumpall restrict/unrestrict tokens in drift check (#112777)
PostgreSQL 16+ added `\restrict` / `\unrestrict` directives to `pg_dumpall` output. These carry random per-session tokens for password scrambling and are not part of the database schema. The migration drift CI job runs `pg_dumpall` twice (once after sequential migrations, once after squashed migrations) and compares the output. Since the tokens are regenerated on every dump, the comparison always reports a false-positive diff — causing the `migrations-drift` workflow to fail on every PR that touches migrations, in both sentry and getsentry. This filters out `\restrict` and `\unrestrict` lines in the `norm()` function, alongside the existing filters for comments and `django_migrations` tables. The `quick_drift_compare.py` script delegates to the same compare module, so both code paths are fixed. Example of the spurious diff this eliminates: ``` -\restrict chSRsrfaJ6ZjA7ck8dSaajbhnPiwOqTaC6ldxf7bN2kbn4VJZk4ODoz8l0XL2pk +\restrict dXbwY4tgrWq0glKas9UkhhnydrGduwSqaYnQMvQj53fxjnB36DA9XvXg3TMMG9U ``` Co-authored-by: Claude Opus 4 <noreply@anthropic.com>
1 parent db8e93c commit 6d3af9d

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)