Installation

Install dpg from a pre-built binary or build from source. Also covers dpg-lsp for editor support.

System Requirements

RequirementMinimum
PostgreSQL target14 or later
OSLinux (amd64/arm64), macOS (amd64/arm64), Windows (amd64)

To build from source, a C compiler (GCC or Clang) and Go 1.25+ are also required — see Build from Source below.


Install from Binary

One-line install (Linux / macOS)

curl -fsSL https://raw.githubusercontent.com/thec1oud/dpg/master/scripts/install.sh | bash

This downloads the correct pre-built binary for your platform and installs it to /usr/local/bin (if sudo is available) or ~/.local/bin (otherwise).

To also install the language server for editor support in one step:

curl -fsSL https://raw.githubusercontent.com/thec1oud/dpg/master/scripts/install.sh | bash -s -- --with-lsp

Install script options

# Install a specific version
bash <(curl -fsSL .../install.sh) --version v0.5.5-alpha.6

# Override install directory
bash <(curl -fsSL .../install.sh) --install-dir ~/.bin

# Preview what would be installed (no changes made)
bash <(curl -fsSL .../install.sh) --check

# Install dpg + dpg-lsp in one step
bash <(curl -fsSL .../install.sh) --with-lsp

Manual download

Download the binary directly from the Releases page:

PlatformArchive
Linux amd64dpg-linux-amd64.tar.gz
Linux arm64dpg-linux-arm64.tar.gz
macOS Inteldpg-darwin-amd64.tar.gz
macOS Apple Silicondpg-darwin-arm64.tar.gz
Windows amd64dpg-windows-amd64.exe.tar.gz

Each archive contains a single binary. Extract it, rename it to dpg (or dpg.exe on Windows), and place it somewhere on your PATH.

Install via go install

If you have Go 1.25+ and a C compiler installed:

go install github.com/thec1oud/dpg/core/cmd/dpg@latest

Install the Language Server (dpg-lsp)

dpg-lsp powers editor features: diagnostics, hover documentation, go-to-definition, and completions.

One-line install (Linux / macOS)

curl -fsSL https://raw.githubusercontent.com/thec1oud/dpg/master/scripts/install-lsp.sh | bash

Or install both dpg and dpg-lsp together:

curl -fsSL https://raw.githubusercontent.com/thec1oud/dpg/master/scripts/install.sh | bash -s -- --with-lsp

Install script options

# Install a specific version
bash <(curl -fsSL .../install-lsp.sh) --version v0.5.5-alpha.3

# Override install directory
bash <(curl -fsSL .../install-lsp.sh) --install-dir ~/.bin

# Preview what would be installed (no changes made)
bash <(curl -fsSL .../install-lsp.sh) --check

Manual download

Download the binary directly from the Releases page:

PlatformArchive
Linux amd64dpg-lsp-linux-amd64.tar.gz
Linux arm64dpg-lsp-linux-arm64.tar.gz
macOS Inteldpg-lsp-darwin-amd64.tar.gz
macOS Apple Silicondpg-lsp-darwin-arm64.tar.gz
Windows amd64dpg-lsp-windows-amd64.zip

Windows: Extract dpg-lsp.exe from the zip and add its directory to your PATH.

Editor setup is covered in Editor Integration.


Build from Source

Additional requirements

RequirementMinimum
Go1.25 or later
CGo toolchainRequired — pg_query_go uses libpg_query (C library)
GCC / ClangMust be on PATH for the CGo build

Because pg_query_go links against the real PostgreSQL C parser, a C compiler must be present. Pure-Go cross-compilation is not possible; each target platform must be built on that platform or with a compatible CGo cross-compilation toolchain.

git clone https://github.com/thec1oud/dpg
cd dpg

Build for the current platform

make build          # produces build/dpg
make install        # installs to $(go env GOPATH)/bin

All make targets

TargetDescription
make buildCompile for the current OS/arch, output build/dpg
make installgo install to $GOPATH/bin
make testgo test ./... — unit tests only, no Docker required
make test-verbosego test ./... -v
make test-integrationgo test -tags integration -count=1 -timeout 5m ./... — requires Docker
make test-examplesgo test ./examples/... -v — runs runnable pipeline examples
make vetgo vet ./...
make lintstaticcheck ./... (requires staticcheck on PATH)
make distCross-compile for all supported platforms into dist/
make dist-linuxBuild linux/amd64 and linux/arm64
make dist-darwinBuild darwin/amd64 and darwin/arm64
make dist-windowsBuild windows/amd64
make cleanRemove ./dpg
make clean-distRemove dist/
make clean-allRemove both
make versionPrint embedded VERSION, COMMIT, DATE
make releaseBuild dist + create compressed archives

Version information

The binary embeds version metadata at build time:

# Build with an explicit version tag
make build v0.5.5-alpha.6=v0.5.5-alpha.6

# The binary reports version info:
dpg --version
# dpg version v0.5.5-alpha.6 (commit: a3f7c91, built: 2026-04-27T00:00:00Z)

If built without VERSION, the value defaults to git describe --tags --always --dirty, or dev if git is unavailable.

Cross-compilation

Because of the CGo requirement, cross-compilation requires a C cross-compiler. The recommended approach is zig cc, which provides hermetic cross-compilation:

# Install zig (https://ziglang.org/download/)
make dist-linux      # uses zig cc for linux/arm64 if not on that arch
make dist-darwin     # requires macOS SDK (only works on macOS hosts)

Verifying the Install

dpg --help
dpg --version

Expected output:

dpg — Declarative PG schema compiler and migration tool

Usage:
  dpg [command]

Available Commands:
  plan         Diff desired state vs snapshot and print the SQL migration
  apply        Execute the planned migration and update the snapshot
  verify       Check the live database for drift against the snapshot
  dump         Introspect a live database and produce initial .dpg source files
  diff         Diff two DPG source directories and print the SQL migration
  portability  Report PostgreSQL-specific constructs in use

Running Tests

make test            # unit tests (no live database required)
make test-examples   # pipeline examples (compilation, diffing, linting, portability)

Integration tests use testcontainers-go to spin up a real PostgreSQL container. They require Docker to be running:

make test-integration
# equivalent to: go test -tags integration -count=1 -timeout 5m ./...