Repository navigation
Closed
Labels
documentationImprovements or additions to documentation
Description
Problem
Fresh self-hosters can set up the database two ways (README → Set up the database, Self-host → Supabase setup):
- CLI —
npx supabase db push: applies every file insupabase/migrations/in order with one command. File count is irrelevant here — zero friction. - Dashboard — paste each migration file and Run, one by one: this is the fallback for people without the CLI, and it scales linearly with the number of migration files. We're already at 20 (
00001_…→00020_…) and it only grows; copy/paste/Run × N is tedious and error-prone (easy to skip a file or run them out of order).
So the friction isn't "too many files" per se — it's that the manual Dashboard path costs work per file. Most CLI users are unaffected.
What we should NOT do
Squashing the existing incremental migrations into one baseline (e.g. supabase migration squash) is tempting but risky: the incremental files are the source of truth and the upgrade path for installs that have already applied 00001…00019, plus they back the managed cloud's migration history. Rewriting that history would desync already-deployed instances. Existing migrations must stay untouched.
Proposed approach — keep both sides
- Incremental migrations stay as-is — the upgrade path for existing installs and the cloud's history. New changes keep landing as new numbered files.
- Add a generated, consolidated
supabase/schema.sql(full schema: tables, indexes, RLS policies, triggers) for fresh installs. Update the Dashboard setup option to "pasteschema.sqlonce and Run" instead of "paste N migration files".- Generate it from the current schema (e.g.
supabase db dump), and regenerate it whenever a migration is added — ideally enforced in CI so it can't drift from the migrations.
- Generate it from the current schema (e.g.
Net result:
- CLI users: keep using
npx supabase db push(unchanged). - Dashboard users: one paste for a fresh install.
- Existing installs / cloud: unaffected — incremental history preserved.
Acceptance criteria
- A consolidated
supabase/schema.sqlexists and provisions a working empty database (all tables, indexes, RLS, triggers) in a single run. - The README and
docs/self-host/supabase-setup.mdxDashboard option point fresh installs atschema.sql; the CLIdb pushpath and the incremental migrations are documented as the upgrade path. - A documented (and ideally CI-enforced) way to regenerate
schema.sqlso it stays in sync as new migrations are added. - Existing incremental migrations are not modified or squashed.
Notes
- Keep the local-dev
supabase/seed.sqldemo fixture separate — it's not part of schema provisioning. schema.sqlis a convenience snapshot for fresh installs only; the numbered migrations remain the authoritative change history.
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentation
Activity
chore(supabase): add generated consolidated schema.sql for fresh inst…