Catalog migrations
Schema migrations for the PeerDB catalog (Postgres), run with goose.
Installing goose cli
go install github.com/pressly/goose/v3/cmd/goose@latest
Create new migration file
goose -dir flow/db/migrations -s create <short_name> sql
The generated template contains placeholder statements and a -- +goose Down section; replace the placeholders and delete the Down section.
Migration guidelines
History and bootstrap from refinery
The catalog was previously migrated by refinery in Rust. Those migrations lived in nexus/catalog/migrations/ as V<n>__<name>.sql and were recorded in public.refinery_schema_history. The files here are the same SQL, renamed to goose's 000<n>_<name>.sql format: version numbers are the shared identity across both tools, which is what makes the cutover safe.
On every run, before applying anything, bootstrapFromRefinery (in migrations.go) translates refinery's ledger into goose's in a single transaction under an advisory lock:
- Probe for both ledger tables. Act only when
goose_db_version is absent and refinery_schema_history is present. A fresh installation skips straight to goose; an already-bootstrapped catalog skips bootstrap after.
- Create
goose_db_version with the same DDL goose itself uses, including goose's version-0 sentinel row.
- Insert one applied row per version actually present in
refinery_schema_history so for a deployment that applied up to V40, goose will apply 41 and up.