examples/

directory
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: MIT

README

Examples

Runnable programs showing the library in context. Each is a package main you can build and run against a real PostgreSQL.

Example Shows
basic/ Migrations from a directory on disk, with os.DirFS.
embedded/ Migrations compiled into the binary with embed.FS.
deploy-gate/ Using Plan to refuse a risky deployment before it starts.

Running them

Start a PostgreSQL — the repository's docker-compose.yml will do:

docker compose up -d --wait
# The compose file maps 5433 on the host, to stay out of the way of a local
# PostgreSQL on the default port.
export DATABASE_URL="postgres://postgres:postgres@localhost:5433/postgres?sslmode=disable"

Then:

go run ./examples/basic
go run ./examples/embedded
go run ./examples/deploy-gate

Each example creates its own bookkeeping table, so they do not interfere.

Directories

Path Synopsis
Command basic applies migrations from a directory on disk.
Command basic applies migrations from a directory on disk.
Command deploy-gate refuses a deployment whose migration plan looks unsafe, before anything is applied.
Command deploy-gate refuses a deployment whose migration plan looks unsafe, before anything is applied.
Command embedded ships its migrations inside the binary with embed.FS, so there is no migrations/ directory to deploy alongside it.
Command embedded ships its migrations inside the binary with embed.FS, so there is no migrations/ directory to deploy alongside it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL