fix: SchemaBot migration validation for order-independent comparison#3917
Merged
fix: SchemaBot migration validation for order-independent comparison#3917
Conversation
philippemnoel
approved these changes
Jan 14, 2026
Member
philippemnoel
left a comment
There was a problem hiding this comment.
If say this works then I believe you!
paradedb-bot
pushed a commit
that referenced
this pull request
Jan 14, 2026
…3917) ## Ticket(s) Closed - Closes #N/A ## What Rewrote the SchemaBot migration file validation to compare SQL statements in an order-independent way, since `pg-schema-diff` output order is non-deterministic. ## Why The previous implementation used exact substring matching (`grep -Fzo` and later a simple Python `in` check), which: 1. Failed when `pg-schema-diff` generated the same functions in a different order 2. Was unreliable with multiline content matching 3. Couldn't handle missing end markers or extra workflow output ## How Created `.github/scripts/check_migration_diff.py` that: - **Strips all comments** - Both `-- ...` and `/* ... */` are removed - **Strips workflow markers** - `--- BEGIN/END SUGGESTED UPGRADE SCRIPT ---` - **Strips psql commands** - `\echo`, `\quit`, etc. - **Extracts SQL statements** - Parses `CREATE`, `ALTER`, `DROP` statements - **Compares as sets** - Order-independent comparison of normalized statements - **Debug mode** - `--debug` flag shows exactly what statements are being compared **Note:** The `--debug` flag is currently enabled in CI to verify stability of the new comparison logic. It will be removed once we confirm it works reliably. ## Tests Verified manually that the check correctly on #3907: - Passes when all schema changes are present (regardless of order) - Fails when schema changes are missing
mdashti
added a commit
that referenced
this pull request
Feb 13, 2026
…3917) ## Ticket(s) Closed - Closes #N/A ## What Rewrote the SchemaBot migration file validation to compare SQL statements in an order-independent way, since `pg-schema-diff` output order is non-deterministic. ## Why The previous implementation used exact substring matching (`grep -Fzo` and later a simple Python `in` check), which: 1. Failed when `pg-schema-diff` generated the same functions in a different order 2. Was unreliable with multiline content matching 3. Couldn't handle missing end markers or extra workflow output ## How Created `.github/scripts/check_migration_diff.py` that: - **Strips all comments** - Both `-- ...` and `/* ... */` are removed - **Strips workflow markers** - `--- BEGIN/END SUGGESTED UPGRADE SCRIPT ---` - **Strips psql commands** - `\echo`, `\quit`, etc. - **Extracts SQL statements** - Parses `CREATE`, `ALTER`, `DROP` statements - **Compares as sets** - Order-independent comparison of normalized statements - **Debug mode** - `--debug` flag shows exactly what statements are being compared **Note:** The `--debug` flag is currently enabled in CI to verify stability of the new comparison logic. It will be removed once we confirm it works reliably. ## Tests Verified manually that the check correctly on #3907: - Passes when all schema changes are present (regardless of order) - Fails when schema changes are missing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket(s) Closed
What
Rewrote the SchemaBot migration file validation to compare SQL statements in an order-independent way, since
pg-schema-diffoutput order is non-deterministic.Why
The previous implementation used exact substring matching (
grep -Fzoand later a simple Pythonincheck), which:pg-schema-diffgenerated the same functions in a different orderHow
Created
.github/scripts/check_migration_diff.pythat:-- ...and/* ... */are removed--- BEGIN/END SUGGESTED UPGRADE SCRIPT ---\echo,\quit, etc.CREATE,ALTER,DROPstatements--debugflag shows exactly what statements are being comparedNote: The
--debugflag is currently enabled in CI to verify stability of the new comparison logic. It will be removed once we confirm it works reliably.Tests
Verified manually that the check correctly on #3907: