Skip to content

fix(supabase): make migration chain replayable from scratch - #85

Merged
YD811 merged 1 commit into
mainfrom
fix/migrations-replayable
Jul 15, 2026
Merged

fix(supabase): make migration chain replayable from scratch#85
YD811 merged 1 commit into
mainfrom
fix/migrations-replayable

Conversation

@YD811

@YD811 YD811 commented Jul 15, 2026

Copy link
Copy Markdown
Owner

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:

File Problem on fresh replay
20260508052206_referrals.sql create table if not exists no-ops (001 already made a legacy-shape referrals), then create index … (referrer_wallet) fails
20260508052225_votes.sql same pattern vs 001's legacy votes (voter/approve)
20260508052217_agent_configs.sql same pattern vs 005's narrower agent_configs (no is_active)
20260508062037_governance_settings_align.sql rename column pot → pot_pubkey — the pot name only existed on old prod; 001 already creates pot_pubkey

Fix

  • The three 2026-05-08 refactor files now drop table if exists … cascade before 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.
  • The governance rename is wrapped in a conditional do block.

Verification

Replayed the full chain (001 → 20260629194328) in order on a scratch Postgres 17 container with a stub auth schema — all 15 files apply cleanly; final votes / referrals / agent_configs / governance_settings shapes match what the UI writes.

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
potbot-v2 Ready Ready Preview, Comment, Open in v0 Jul 15, 2026 8:03pm

Request Review

@supabase

supabase Bot commented Jul 15, 2026

Copy link
Copy Markdown

Updates to Preview Branch (fix/migrations-replayable) ↗︎

Deployments Status Updated
Database Wed, 15 Jul 2026 20:00:05 UTC
Services Wed, 15 Jul 2026 20:00:05 UTC
APIs Wed, 15 Jul 2026 20:00:05 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Wed, 15 Jul 2026 20:00:10 UTC
Migrations Wed, 15 Jul 2026 20:00:10 UTC
Seeding Wed, 15 Jul 2026 20:00:12 UTC
Edge Functions Wed, 15 Jul 2026 20:00:13 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@YD811
YD811 merged commit 1645865 into main Jul 15, 2026
8 checks passed
@YD811
YD811 deleted the fix/migrations-replayable branch July 15, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant