Database schema changes are managed as SQL migration files inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ency07/B2B/llms.txt
Use this file to discover all available pages before exploring further.
supabase/migrations/ with UTC timestamps as filenames. There are no automatic down migrations — rollbacks are executed manually with reverse SQL statements. Every migration file is reviewed before it reaches production.
File naming convention
Migration files follow the formatYYYYMMDDHHMMSS_description.sql:
Applying migrations
Create the migration file
Add a new Write your
.sql file in supabase/migrations/ using the next UTC timestamp as the filename prefix:CREATE TABLE, ALTER TABLE, CREATE INDEX, and CREATE POLICY statements inside the file.Point .env.local at the correct project
Verify that
.env.local contains the Supabase URL and service-role key for the target environment (local, staging, or production) before executing the migration script.New table checklist
Every new table must satisfy this checklist before its migration file is committed:Enable Row Level Security
public schema, including lookup/reference tables.Create RLS policies
Create policies for the roles that need access. Always scope data access by
tenant_id:Migration environments
| Environment | Command | .env target |
|---|---|---|
| Development | npx ts-node scripts/deploy-migrations.ts | .env.local → local Supabase |
| Staging | npx ts-node scripts/deploy-migrations.ts | .env.local → staging project |
| Production | Manual SQL review + deploy-migrations.ts | .env.local → prod project |
npx ts-node scripts/setup-env.ts <env> to quickly switch .env.local between targets.
Rollback SQL reference
Use these patterns to reverse common migration types directly in the Supabase Dashboard SQL Editor:Production checklist
Run through this checklist for every migration that targets the production Supabase project:Take a manual backup
Get a second-engineer review
Open a PR or send the migration SQL to a second engineer. Confirm: no destructive changes to existing data, correct RLS policies, and all foreign keys reference valid tables.
Apply to staging first
Point Verify the staging app works end-to-end before proceeding.
.env.local at the staging project and run: