Skip to content

ci: replay migrations against a real Postgres, replacing the dead Supabase check - #498

Merged
ArnasDon merged 6 commits into
mainfrom
ci/validate-migrations
Aug 12, 2026
Merged

ci: replay migrations against a real Postgres, replacing the dead Supabase check#498
ArnasDon merged 6 commits into
mainfrom
ci/validate-migrations

Conversation

@ArnasDon

Copy link
Copy Markdown
Owner

Draft while I confirm the job goes green — I have no container runtime locally, so this is the first time it can actually run.

Replaces the Supabase Preview check, which has never validated anything. See the commit message for the diagnosis; short version: two stale dashboard integrations, one 404ing and one hanging, and Branching needs a supabase/config.toml this repo never had. Every migration in this repo has shipped unexecuted by CI.

This job boots a throwaway Postgres with the Supabase CLI, replays every migration from nothing, and then asserts a few of the resulting objects exist (the DDL here is all IF NOT EXISTS-guarded, so "no error" alone doesn't prove anything got built). No secrets, no Supabase account, no paid plan.

You still need to disconnect the two dashboard integrations by hand — Integrations → GitHub in the Supabase dashboard. That can't be done from the repo, and until it is, the dead check keeps appearing alongside this one.

🤖 Generated with Claude Code

…abase check

The "Supabase Preview" check has never validated anything. Two stale
dashboard integrations are wired to this repo, and neither can
provision: one 404s in four seconds with "Postgres config not found",
the other hangs forever on "Waiting for branch action run to complete"
because Supabase Branching needs a supabase/config.toml that this repo
has never had. It also only fires when supabase/migrations/ changes, so
most PRs show no Supabase check at all and the red X looks intermittent
rather than permanent.

The upshot is that every migration in this repo has shipped unexecuted
by CI — 39 files whose first real run is against production data.

This job does what that check only claimed to. It boots a throwaway
Postgres with the Supabase CLI and replays every migration from
nothing, in order, failing on the first statement Postgres rejects. No
secrets, no Supabase account, no paid plan: the database runs in a
container on the runner.

It then asserts a handful of resulting objects exist. Every DDL
statement in this repo is IF NOT EXISTS-guarded so the files can be
re-run safely, and that same guard turns a typo'd object name into a
silent no-op with a green checkmark — so "no error" is not on its own
evidence that anything was built.

config.toml is deliberately minimal. It is what the CLI needs to
recognise a project directory, not a copy of the hosted project's
settings, which stay in the dashboard rather than becoming a second
source of truth that drifts. Its major_version is the CLI default and
should be aligned with the live project's Postgres version.

The dashboard integrations still need disconnecting by hand; that
cannot be done from the repo.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@supabase

supabase Bot commented Aug 12, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project crxylxakpapcfziradbb due to reaching the limit of concurrent preview branches.
Go to Project Integrations Settings ↗︎ if you wish to update this limit.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Temporary. A green check that cannot go red is exactly the failure this
PR is replacing, so assert something false once and watch CI.
Run 31579334056 went red with the deliberate assertion in place, so a
RAISE in verify-schema.sql does fail the job. Recorded in the file.
supabase db query --file is one prepared statement, so a second
top-level DO fails with 'cannot insert multiple commands'. Documented.
Migration 039 belongs to PR #496, not here. It applied cleanly to a
clean Postgres 17 and produced the columns and widened bucket
allow-list it claims (commit 65c99d8), which was the open risk on that
PR. Removing it leaves this branch to main's 38 migrations.
@ArnasDon
ArnasDon marked this pull request as ready for review August 12, 2026 08:54
@ArnasDon

Copy link
Copy Markdown
Owner Author

Out of draft — the job is green and, more to the point, proven able to go red.

What CI established (not assumed):

  • All 38 migrations on main apply to a clean Postgres 17 with Supabase's auth/storage schemas present. First time that has ever run.
  • The check can fail. A deliberately false assertion (commit 42c7db0, run 31579334056) turned the job red with a clear message, then I reverted it. Worth doing given this PR exists because the old check passed by not working.
  • supabase/ci/verify-schema.sql must be exactly one statement — db query --file sends it as a prepared statement and a second top-level DO dies with "cannot insert multiple commands into a prepared statement". Found the hard way (f91a6c8); documented in the file.
  • Migration 039 from feat: mirror inbound media into chat-media so attachments survive Meta's 30-day expiry #496 applies cleanly and produces the columns and widened bucket allow-list it claims (65c99d8). I borrowed it into a run here and then stripped it, so that PR's open "never executed anywhere" risk is now closed.

Runtime is ~1m45s, and it only fires on supabase/** changes.

Two caveats:

  • config.toml sets major_version = 17, which is the CLI default and not a reading of the live project. If production is on 15, align it — otherwise this check can green-light SQL production would reject, which defeats the point.
  • The two dead dashboard integrations still need removing by hand (Integrations → GitHub). Until then Supabase Preview keeps appearing next to this job; you can see it going skipped on the commits here that didn't touch supabase/migrations/.

@ArnasDon
ArnasDon merged commit 8c26bbd into main Aug 12, 2026
3 checks passed
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