mirror of
https://github.com/xataio/pgroll.git
synced 2024-10-26 13:52:56 +03:00
a8c4fddd14
This migrations introduces state handling by creating a dedicated `pgroll` schema (name configurable). We will store migrations there, as well as their state. So we keep some useful information, ie the migration definition (so we don't need it for the `complete` state). Schema includes the proper constraints to guarantee that: * Only a migration is active at a time * Migration history is linear (all migrations have a unique parent, except the first one which is NULL) * We now the current migration at all times Some helper functions are included: * `is_active_migration_period()` will return true if there is an active migration. * `latest_version()` will return the name of the latest version of the schema.
681 B
681 B
pg-roll
⚠️ Under development ⚠️
PostgreSQL zero-downtime migrations made easy.
Getting started (development)
-
Bring a development PostgreSQL up:
docker compose up
-
Initialize pg-roll (first time only):
go run . init
-
Start a migration:
go run . start examples/01_create_tables.json
-
Inspect the results:
psql postgres://localhost -U postgres
\d+ public.* \d+ 01_create_tables.*
-
(Optional) Rollback the migration (undo):
go run . rollback
-
Complete the migration:
go run . complete