A PostgreSQL schema management tool
pglifecycle keeps your database schema in a version-controlled project of YAML files — one file per database object, validated against a JSON-Schema contract — and moves schema between the repository and live databases:
pullreads a live database (or apg_dumparchive) and writes the project directorybuildturns the project into apg_restore-compatible custom format archivecreatescaffolds an empty project
brew tap gmr/postgres
brew install pglifecycleNote
Homebrew 6.0 added tap trust, and some
versions fail to install third-party taps inside the build sandbox (the
error mentions build.rb ... exited with 1). If you hit this, trust the
formula first:
brew trust --formula gmr/postgres/pglifecycleor, as a temporary workaround, set HOMEBREW_NO_REQUIRE_TAP_TRUST=1 for
the install.
cargo install pglifecyclePrebuilt binaries for Linux and macOS (x86_64 and aarch64) are attached to each release.
# pull an existing database into a new project
pglifecycle pull -h localhost -d mydb my-project/
# build the project into a restorable archive
pglifecycle build my-project/ mydb.dump
pg_restore -d mydb_copy mydb.dumpSee the documentation for the full command reference and project format.