github.com/supabase/cli@v1.168.1/internal/utils/templates/initial_schemas/README.md (about)

     1  # About Initial Schemas
     2  
     3  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.
     4  
     5  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.
     6  
     7  # Why use the pg_dump output instead of running the `init.sql` directly?
     8  
     9  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.
    10  
    11  # How to Generate Initial Schemas
    12  
    13  1. Start supabase local development stack with default config
    14  
    15  ```bash
    16  go run . init
    17  go run . start -x gotrue,storage-api,imgproxy
    18  ```
    19  
    20  2. Run the initial dump script and pipe output to `15.sql`
    21  
    22  ```bash
    23  ./tools/dump_initial_schema.sh > internal/utils/templates/initial_schemas/15.sql
    24  ```
    25  
    26  3. Commit changes that are relevant for the update
    27  
    28  - `INSERT INTO _realtime.extensions` and `_realtime.tenants` usually do not require updating.
    29  - `INSERT INTO *.schema_migrations` statements are only required if there are new migrations.
    30  - `ALTER EVENT TRIGGER issue_pg_cron_access OWNER TO` should be followed by `supabase_admin`.
    31  
    32  4. Set `major_version = 14` in `supabase/config.toml` and repeat steps 1-3 to update `14.sql`
    33  5. Set `major_version = 13` in `supabase/config.toml` and repeat steps 1-3 to update `13.sql`