1.6 KiB
1.6 KiB
About Initial Schemas
These SQL files represent initial schemas needed to set up the database with Supabase stuff. These need to be manually generated for each Postgres major version. Which initial schema used depends on the Docker image tag used to run the local db, which in turn depends on the CLI's db.major_version config.
The initial schema for PG12 is not available because the latest image (supabase/postgres:12.5.0) doesn't contain wal2json, which is required for Realtime to work.
Why use the pg_dump output instead of running the init.sql directly?
Because Realtime, GoTrue, Logflare, and Storage have their own migrations, and these need to be included in the initial schema for e.g. supabase db reset to work.
How to Generate Initial Schemas
- Start supabase local development stack with default config
go run . init
go run . start -x gotrue,storage-api,imgproxy
- Run the initial dump script and pipe output to
15.sql
./tools/dump_initial_schema.sh > internal/utils/templates/initial_schemas/15.sql
- Commit changes that are relevant for the update
INSERT INTO _realtime.extensionsand_realtime.tenantsusually do not require updating.INSERT INTO *.schema_migrationsstatements are only required if there are new migrations.ALTER EVENT TRIGGER issue_pg_cron_access OWNER TOshould be followed bysupabase_admin.
- Set
major_version = 14insupabase/config.tomland repeat steps 1-3 to update14.sql - Set
major_version = 13insupabase/config.tomland repeat steps 1-3 to update13.sql