Skip to content
Browse guides

Maintain

Supabase

Versioned migrations, generated types, and cloud authorization.

Docs index | Operations | Local development | Environment and secrets

Kocteau uses two Supabase workflows:

  • Contributors use the Docker-backed local stack.
  • Maintainers use versioned migrations against Supabase Cloud projects.

This keeps public contribution safe while letting maintainers operate like a SaaS project with staging, production, and migration history.

CLI Installation

The Supabase CLI is installed as a repo dev dependency:

pnpm exec supabase --version
pnpm supabase:version

Do not rely on a global supabase binary. Use pnpm scripts so everyone runs the version pinned by the repo lockfile.

CLI Credential Compatibility

CLI 2.109.1 contains both newer management commands and legacy database commands. On Linux, a browser login stored in the keyring can work for project/history reads while a legacy database command reports a missing token. A successful project listing alone does not verify migration credentials.

For that case, provide the authenticated credential through the supported SUPABASE_ACCESS_TOKEN environment variable using a private secret store. Keep its value out of command arguments, repository files and diagnostics. Re-run the pinned dry run before applying any migration; missing credentials still mean delivery is pending.

Environment Model

Use separate Supabase Cloud projects:

  • Development cloud: maintainer-only experiments that need real cloud behavior.
  • Staging: production-shaped verification before launch.
  • Production: real users and canonical data.

Contributors should not connect to any cloud project by default. Their workflow remains local:

pnpm supabase:start
pnpm supabase:reset
pnpm supabase:types
pnpm dev:web

Maintainer Commands

Use these for cloud work:

pnpm supabase:login
pnpm supabase:link --project-ref <project-ref>
pnpm supabase:migration:list:linked
pnpm supabase:db:push:dry
pnpm supabase:db:lint:linked
pnpm supabase:db:advisors:linked
pnpm supabase:db:push
pnpm supabase:types:linked

Use these for migration authoring:

pnpm supabase:migration:new descriptive_name
pnpm supabase:reset
pnpm supabase:lint
pnpm supabase:types

Use these for local contributor-compatible checks:

pnpm supabase:start
pnpm supabase:status
pnpm supabase:reset
pnpm supabase:lint
pnpm supabase:types

Migration Rules

  • Migration delivery includes CLI execution and verification. A checked-in SQL file is not evidence that a database was migrated.
  • Cloud writes require the maintainer's authorization for this repository and target environment. When that authorization already covers the current work, execute the workflow without requesting it again. Contributors and other repositories establish their own authorization; do not inherit another user's consent. Resets, migration-history repairs, and destructive maintenance are separate operations.
  • Before applying, confirm the linked target and inspect every pending migration. After applying, check linked history, exercise the affected permissions/flow, regenerate types, and record the result in CURRENT.md. Report any unavailable credential, execution failure, or unverified flow explicitly as pending.
  • Every schema change must be in supabase/migrations.
  • Every exposed table needs RLS and explicit grants.
  • Sensitive writes should go through server routes or curator-only RPCs.
  • Run pnpm supabase:db:push:dry before any cloud push.
  • Do not use supabase db reset against cloud databases.
  • Do not run supabase/scripts/maintenance unless the script is reviewed for that target environment.
  • Regenerate types after migrations are applied to the environment being verified.

Development Workflow

For normal product work:

  1. Create or edit migration SQL in supabase/migrations.
  2. Test locally with Docker:
pnpm supabase:reset
pnpm supabase:lint
pnpm supabase:types
pnpm --filter web lint
pnpm --filter web build
  1. Open a PR with the migration and generated types.

Staging Workflow

After a PR is ready:

  1. Link the staging project:
pnpm supabase:link --project-ref <staging-ref>
  1. Check migration history:
pnpm supabase:migration:list:linked
  1. Preview pending migrations:
pnpm supabase:db:push:dry
  1. Apply migrations only after reviewing the dry run:
pnpm supabase:db:push
pnpm supabase:db:lint:linked
pnpm supabase:db:advisors:linked
pnpm supabase:types:linked
  1. Deploy the staging web app and manually verify the affected flows.

Production Workflow

Production follows the same shape as staging, with more ceremony:

  1. Confirm staging has passed.
  2. Confirm the migration list is in sync.
  3. Take or confirm an available backup for risky schema work.
  4. Run:
pnpm supabase:db:push:dry
  1. Review pending migration names and SQL.
  2. Apply:
pnpm supabase:db:push
pnpm supabase:db:lint:linked
pnpm supabase:db:advisors:linked
  1. Deploy web.
  2. Run post-deploy checks from operations.

Branch And Project Hygiene

  • Keep .temp and any local Supabase state out of git.
  • Do not commit access tokens, database URLs, passwords, service role keys, or cloud anon keys.
  • If a cloud project and local migrations diverge, stop and inspect with pnpm supabase:migration:list:linked before using repair commands.
  • Repair commands require maintainer review because they change migration history.

Docker Boundary

Docker remains required for contributor local Supabase and local migration resets.

Maintainers do not need Docker for daily cloud operations such as:

pnpm supabase:migration:list:linked
pnpm supabase:db:push:dry
pnpm supabase:db:push
pnpm supabase:types:linked

Use Docker when you want local parity before a PR. Use Cloud when you are deploying versioned migrations to staging or production.