fix(schema): re-sync schema.sql with the chats-overview migration; make the drift gate required - #330
Draft
amal66 wants to merge 1 commit into
Draft
Conversation
….sql The schema-drift gate compares a fresh install (schema.sql) against an upgraded deployment (baseline + replayed migrations) by fingerprinting both databases. Function bodies are opaque strings to Postgres, so they compare textually — and 57d754c shipped migration 20260812_01_collection_pagination_queries.sql rewriting get_chats_overview with the ownership predicate split across four lines while schema.sql kept the one-line form. Same semantics, different bytes: the gate has been red on main and on every PR rebased onto it since. schema.sql now carries the migration's exact text — the whole function definition is byte-identical between the two files — which is the gate's own prescription: when a migration merges without being folded into schema.sql, schema.sql is what gets updated, never the already-shipped migration. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
TL;DR
The Schema drift gate ("Fresh install vs upgraded deployment") has been red on
mainsince 57d754c. This PR makesbackend/schema.sqlcarry the exact text of theget_chats_overviewdefinition that migration20260812_01_collection_pagination_queries.sqlships — a formatting-only change, no semantic difference — which restores the fresh-install and upgrade paths to identical fingerprints. It also proposes making this check required onmain(instructions below — needs repo admin).Root cause
57d754c ("fix: harden collection pagination and directory loading") rewrote
get_chats_overviewin the migration with the ownership predicate split across four lines:while
schema.sqlkept the same predicate on one line. Postgres stores SQL-language function bodies as opaque strings, so the drift gate — correctly — compares them textually: same semantics, different bytes, fingerprints diverge. Every push tomainand every PR rebased onto it has carried the red check since (e.g. #251's rebase inherited it).The fix
Exactly what the gate's own failure message prescribes: a migration was merged without being folded into
schema.sql, so updateschema.sql— never the already-shipped migration. After this change the entireget_chats_overviewdefinition is byte-identical betweenbackend/schema.sqland the migration (verified by extracting and diffing both definitions). One file, formatting only; the deployed function this produces is unchanged.Verification
The Schema drift workflow runs on this PR — its result on this branch is the test, since the failing comparison (baseline + all migrations vs. this
schema.sql) is exactly what the job executes.Making this check required (needs admin — @willchen96)
This incident is the argument: the gate caught the drift immediately, but nothing stopped the merge, so
mainstayed red and every open PR inherited a failure it didn't cause. TheProtect mainruleset currently requires a PR with one approval but no status checks at all. To make this one blocking:Fresh install vs upgraded deployment(source: GitHub Actions). Optionally enable "Require branches to be up to date before merging" so the comparison always runs against current migrations.Backend build and tests,Frontend build and tests,dependency-audit (root/backend/frontend),gitleaks (full history)) — today none of them block a merge either.I'd have flipped it directly, but ruleset edits need admin on the repo and this account only has push.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XHBa7CRB3MBRyy3YJd7h8z