Skip to content

gmr/pglifecycle

Repository files navigation

pglifecycle

A PostgreSQL schema management tool

Crates.io Testing License

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:

  • pull reads a live database (or a pg_dump archive) and writes the project directory
  • build turns the project into a pg_restore-compatible custom format archive
  • create scaffolds an empty project

Installation

Homebrew (macOS / Linux)

brew tap gmr/postgres
brew install pglifecycle

Note

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/pglifecycle

or, as a temporary workaround, set HOMEBREW_NO_REQUIRE_TAP_TRUST=1 for the install.

Cargo

cargo install pglifecycle

Prebuilt binaries for Linux and macOS (x86_64 and aarch64) are attached to each release.

Usage

# 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.dump

See the documentation for the full command reference and project format.

About

A PostgreSQL schema management tool

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors