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:drybefore any cloud push. - Do not use
supabase db resetagainst cloud databases. - Do not run
supabase/scripts/maintenanceunless 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:
- Create or edit migration SQL in
supabase/migrations. - Test locally with Docker:
pnpm supabase:reset
pnpm supabase:lint
pnpm supabase:types
pnpm --filter web lint
pnpm --filter web build
- Open a PR with the migration and generated types.
Staging Workflow
After a PR is ready:
- Link the staging project:
pnpm supabase:link --project-ref <staging-ref>
- Check migration history:
pnpm supabase:migration:list:linked
- Preview pending migrations:
pnpm supabase:db:push:dry
- 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
- Deploy the staging web app and manually verify the affected flows.
Production Workflow
Production follows the same shape as staging, with more ceremony:
- Confirm staging has passed.
- Confirm the migration list is in sync.
- Take or confirm an available backup for risky schema work.
- Run:
pnpm supabase:db:push:dry
- Review pending migration names and SQL.
- Apply:
pnpm supabase:db:push
pnpm supabase:db:lint:linked
pnpm supabase:db:advisors:linked
- Deploy web.
- Run post-deploy checks from operations.
Branch And Project Hygiene
- Keep
.tempand 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:linkedbefore 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.