Supported Operating Systems
Windows is not supported. Please use WSL (Windows Subsystem for Linux) or a Linux VM.
- Linux (AMD64, ARM64)
- macOS (Apple Silicon, Intel)
macOS
Homebrew (Recommended)
Pre-built Binary
Install pgschema using Homebrew:# Install pgschema
brew tap pgschema/pgschema
brew install pgschema
# Verify installation
pgschema --help
To update to the latest version: Download and install the pre-built binary for macOS.# Download the binary
curl -L https://github.com/pgschema/pgschema/releases/download/v1.0.0/pgschema-1.0.0-darwin-arm64 -o pgschema
# Make it executable
chmod +x pgschema
# Move to PATH
sudo mv pgschema /usr/local/bin/
# Verify installation
pgschema --help
Debian/Ubuntu (DEB)
Install pgschema using the DEB package on Debian, Ubuntu, or other Debian-based distributions.
# Download the DEB package
curl -LO https://github.com/pgschema/pgschema/releases/download/v1.0.0/pgschema_1.0.0_amd64.deb
# Install the package
sudo dpkg -i pgschema_1.0.0_amd64.deb
# Verify installation
pgschema --help
# Download the DEB package
curl -LO https://github.com/pgschema/pgschema/releases/download/v1.0.0/pgschema_1.0.0_arm64.deb
# Install the package
sudo dpkg -i pgschema_1.0.0_arm64.deb
# Verify installation
pgschema --help
RedHat/Fedora (RPM)
Install pgschema using the RPM package on RedHat, Fedora, CentOS, or other RPM-based distributions.
# Download the RPM package
curl -LO https://github.com/pgschema/pgschema/releases/download/v1.0.0/pgschema-1.0.0-1.x86_64.rpm
# Install the package
sudo rpm -i pgschema-1.0.0-1.x86_64.rpm
# Verify installation
pgschema --help
# Download the RPM package
curl -LO https://github.com/pgschema/pgschema/releases/download/v1.0.0/pgschema-1.0.0-1.aarch64.rpm
# Install the package
sudo rpm -i pgschema-1.0.0-1.aarch64.rpm
# Verify installation
pgschema --help
Pre-built Binaries (Linux)
For Linux systems without package manager support, download pre-built binaries from the GitHub releases page.
# Download the binary
curl -L https://github.com/pgschema/pgschema/releases/download/v1.0.0/pgschema-linux-amd64 -o pgschema
# Make it executable
chmod +x pgschema
# Move to PATH
sudo mv pgschema /usr/local/bin/
# Verify installation
pgschema --help
# Download the binary
curl -L https://github.com/pgschema/pgschema/releases/download/v1.0.0/pgschema-linux-arm64 -o pgschema
# Make it executable
chmod +x pgschema
# Move to PATH
sudo mv pgschema /usr/local/bin/
# Verify installation
pgschema --help
Docker
Run pgschema using Docker without installing it locally:
# Pull the latest image
docker pull pgschema/pgschema:latest
# Run pgschema commands
docker run --rm pgschema/pgschema:latest --help
# Dump a localhost database (requires --network host)
docker run --rm --network host \
-e PGPASSWORD=mypassword \
pgschema/pgschema:latest dump \
--host localhost \
--port 5432 \
--db mydb \
--schema public \
--user myuser > schema.sql
# Plan migration and save to plan.json on host
docker run --rm --network host \
-v "$(pwd):/workspace" \
-e PGPASSWORD=mypassword \
pgschema/pgschema:latest plan \
--host localhost \
--port 5432 \
--db mydb \
--schema public \
--user myuser \
--file /workspace/schema.sql \
--output-json /workspace/plan.json
# Apply changes using the saved plan.json
docker run --rm --network host \
-v "$(pwd):/workspace" \
-e PGPASSWORD=mypassword \
pgschema/pgschema:latest apply \
--host localhost \
--port 5432 \
--db mydb \
--schema public \
--user myuser \
--plan /workspace/plan.json
Important Docker Usage Notes:
- Use
--network host when connecting to databases on localhost/127.0.0.1
- Mount volumes with
-v "$(pwd):/workspace" to access local schema files
- Files inside the container should be referenced with
/workspace/ prefix
Go Install
If you have Go 1.24.0 or later installed, you can install pgschema directly:
go install github.com/pgschema/pgschema@latest
This will install the latest version of pgschema to your $GOPATH/bin directory.
After installation, verify that pgschema is working correctly:
# View help and check version
pgschema --help
Build from Source
Clone the repository and build from source:
# Clone the repository
git clone https://github.com/pgschema/pgschema.git
cd pgschema
# Build the binary
go build -v -o pgschema .
# Optional: Install to system
sudo mv pgschema /usr/local/bin/
Building from source requires Go 1.24.0 or later.