Goose applies incremental SQL or Go migrations across Postgres, MySQL, SQLite, and several other databases. It ships as a command-line tool and as a Go library.
Overview
Goose is a database migration tool for managing schema through versioned SQL files or Go functions. You can create migrations, apply them forward, roll back, inspect status, and target specific versions with commands such as up, down, up-to, and down-to.
It works against multiple database engines, including Postgres, MySQL, MariaDB, Spanner, SQLite, YDB, ClickHouse, MSSQL, and Vertica. SQL migrations use goose Up and Down annotations in comments, support optional non-transactional statements, multi-statement blocks, and environment variable substitution in SQL. Go migrations run as registered functions when you build a custom goose binary that imports the goose package.
The CLI can load connection settings from environment variables or .env files. Features described in the documentation include out-of-order migration handling with an allow-missing option, data seeding, hybrid timestamp and sequential versioning for teams, and embedding SQL migrations into Go binaries for read-only apply paths.
Installation options include a binary via Go install, Homebrew on macOS, and a minimal container image for linux/amd64 and linux/arm64 that runs .sql migrations from a /migrations working directory. Driver-specific notes apply for databases such as MySQL parseTime and multiStatements, and ClickHouse deployment modes.
Key features
- Incremental SQL and Go migrations
- Up, down, status, and version commands
- Out-of-order migration support
- Environment variable substitution in SQL
- Embedded SQL migrations in Go binaries
- Data seeding support
- Hybrid timestamp and sequential versioning
- Multi-database driver support
Use cases
- Versioning relational database schema changes
- Rolling back failed migrations in production
- Running complex Go logic inside migrations
- Applying migrations from CI with a container image
- Team workflows with timestamped dev migrations