fix(supabase): make migration chain replayable from scratch - #85
Merged
Conversation
The Supabase Preview check replays every migration on a fresh preview
database, where four files fail because they assume the shape the old
production DB had rather than what the earlier migrations in this repo
create:
- 20260508052206_referrals.sql, 20260508052225_votes.sql,
20260508052217_agent_configs.sql: each does create-table-if-not-exists
for a table an earlier migration (001/005) already created with an
older column set, so the create silently no-ops and the following
index/policy statements hit missing columns
('column "referrer_wallet" does not exist'). Fixed by dropping the
legacy table first — these versions are already recorded on the live
DB, so the files never re-run there; the drop only affects fresh
replays, which have no data.
- 20260508062037_governance_settings_align.sql: renames column pot →
pot_pubkey, but that shape only existed on the old production DB; a
fresh replay creates pot_pubkey directly in 001 and the rename errors.
Renames are now conditional on the column existing.
Verified: full chain (001 → 20260629194328) replays cleanly on a
scratch Postgres 17 with a stub auth schema.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Updates to Preview Branch (fix/migrations-replayable) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
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.
Fixes the Supabase Preview check failure (
column "referrer_wallet" does not exist) that appeared on PR #84 once the migration-history sync landed.Root cause
The preview check replays all local migrations on a fresh database. Four files assumed the old production DB shape instead of what the repo's own earlier migrations create:
20260508052206_referrals.sqlcreate table if not existsno-ops (001 already made a legacy-shapereferrals), thencreate index … (referrer_wallet)fails20260508052225_votes.sqlvotes(voter/approve)20260508052217_agent_configs.sqlagent_configs(nois_active)20260508062037_governance_settings_align.sqlrename column pot → pot_pubkey— thepotname only existed on old prod; 001 already createspot_pubkeyFix
drop table if exists … cascadebefore creating the new shape. These versions are already recorded on the live DB, so the files never re-run there — the drop only affects fresh replays, which have no data by definition.doblock.Verification
Replayed the full chain (001 → 20260629194328) in order on a scratch Postgres 17 container with a stub
authschema — all 15 files apply cleanly; finalvotes/referrals/agent_configs/governance_settingsshapes match what the UI writes.🤖 Generated with Claude Code