Skip to content

chore(self-host): add a consolidated schema.sql for fresh installs (keep incremental migrations as the upgrade path) #309

Closed

Description

@gkhngyk

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 in supabase/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

  1. Incremental migrations stay as-is — the upgrade path for existing installs and the cloud's history. New changes keep landing as new numbered files.
  2. Add a generated, consolidated supabase/schema.sql (full schema: tables, indexes, RLS policies, triggers) for fresh installs. Update the Dashboard setup option to "paste schema.sql once 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.

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.sql exists and provisions a working empty database (all tables, indexes, RLS, triggers) in a single run.
  • The README and docs/self-host/supabase-setup.mdx Dashboard option point fresh installs at schema.sql; the CLI db push path and the incremental migrations are documented as the upgrade path.
  • A documented (and ideally CI-enforced) way to regenerate schema.sql so it stays in sync as new migrations are added.
  • Existing incremental migrations are not modified or squashed.

Notes

  • Keep the local-dev supabase/seed.sql demo fixture separate — it's not part of schema provisioning.
  • schema.sql is a convenience snapshot for fresh installs only; the numbered migrations remain the authoritative change history.

Activity

  1. added
    documentation
    on Jun 27, 2026
  2. added a commit that references this issue on Jul 2, 2026
    b9ef781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions