Repository navigation
Description
Problem
A pull request that adds a file under supabase/migrations/ needs one manual step after merge: applying it to the hosted database. Nothing in the process carries that reminder, and it has now been missed twice.
#709 — prompt_suggestions was created directly against the hosted database and never written into a migration. Every fresh install broke from the moment that migration shipped.
Today — 00050_content_opportunity_aggregates.sql merged with #700 and was never applied. content_opportunity_aggregates did not exist in the database, so the Content page returned "Failed to list opportunities" for all fifty brands holding 7,561 opportunities. The file was correct; only the apply step was missing.
Both were contributor pull requests, and that is the pattern: when we open a PR ourselves we apply the migration before merging and note it, but nothing carries that step across a merge someone else authored.
The gap was found by a customer-visible error, not by us. That is the part worth fixing.
Proposal
Add a CI job that fails, or at minimum comments, when a pull request adds or modifies a file under supabase/migrations/. It does not need to know anything about the database — the diff is the whole signal:
migrations:
name: migrations — new migration needs applying
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- name: Detect migration changes
run: |
CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- supabase/migrations/)
if [ -n "$CHANGED" ]; then
echo "::warning::This PR changes migrations. Apply them to the hosted database before or immediately after merge:"
echo "$CHANGED"
fiWhether it should fail the check or only annotate is the open question. A hard failure cannot be ignored but blocks a PR for something that is not wrong with the code; an annotation is easy to scroll past, which is exactly how this was missed. A label applied automatically — say needs-migration — sits between the two and survives on the merged PR as a record.
A second, cheaper safety net
Regardless of the CI job, a short read-only script that compares what the repo declares against what the database has would have caught both incidents in seconds:
- every
CREATE FUNCTION public.xinsupabase/migrations/exists inpg_proc - every
CREATE TABLE public.xexists inpg_tables - every
.rpc('x')call inweb/srcandserver/srcresolves to a function that exists
The last check is the strongest of the three: it verifies what the application actually calls, not merely what the migrations declare. Running it against the hosted database just now found no further gaps beyond the one fixed today — 16 functions, 43 tables and 14 called RPCs all present — so this is about keeping it that way rather than an outstanding problem.
Acceptance criteria
- A pull request touching
supabase/migrations/is visibly marked as such, in a way that persists on the merged PR rather than only in a check that scrolls away. - A pull request touching nothing under that path is unaffected.
- The check needs no database credentials — GitHub Actions must not hold them for this.
- If the drift script lands too, it is documented in
CONTRIBUTING.mdalongsidebash supabase/build-schema.shso it is part of the routine rather than folklore.
Activity
ci: flag pull requests that change a migration so the apply step is n…