Database Migrations
All database schema changes are tracked as SQL migration files in supabase/migrations/. Each file is timestamped and applied in order.
Applying Migrations
Local development
These commands require a linked Supabase project (supabase link --project-ref <ref>) or a local Supabase instance started with supabase start:
# Apply all pending migrations
supabase db push
# Reset and re-apply all migrations (destructive — local only)
supabase db reset --no-seedProduction
Migrations run automatically on container startup via the docker-entrypoint.sh script using scripts/run-migrations.mjs. This script:
- Connects to the configured Supabase instance
- Checks which migrations have already been applied
- Applies any pending migrations in order
- Logs the result
Migrations are idempotent — running against an up-to-date database is a no-op.
Manual application
You can also apply migrations manually via the Supabase SQL editor or psql:
psql $DATABASE_URL -f supabase/migrations/20251027000001_data_as_a_service_schema.sqlMigration Files
Files are named YYYYMMDDHHMMSS_description.sql and applied in lexicographic order. Examples from the current set:
| File | Description |
|---|---|
20251027000001_data_as_a_service_schema.sql | Core tables: daas_users, daas_roles, etc. |
20251030000001_enable_row_level_security.sql | Row-Level Security policies |
20251030000003_create_audit_logging.sql | Audit triggers on system tables |
20251028000001_add_get_tables_function.sql | PostgreSQL helper functions |
20260212000001_rename_prefix_to_daas.sql | Table renames and schema migration |
Creating a New Migration
supabase migration new my_migration_name
# Creates: supabase/migrations/<timestamp>_my_migration_name.sqlWrite your SQL in the generated file, then apply it (requires a linked project or local instance):
supabase db push