About this project

Goose is a database migration tool distributed as both a command-line interface and a Go library. It manages database schema evolution through incremental migration files written either as SQL or as Go functions. Supported databases include Postgres, MySQL, MariaDB, Spanner, SQLite, YDB, ClickHouse, MSSQL, Vertica, Redshift, TiDB, StarRocks, Turso and Azure SQL. The binary can be trimmed by excluding unneeded drivers via build tags. Installation is available through `go install`, Homebrew on macOS, or a custom build. Configuration can be passed as command arguments or through environment variables such as GOOSE_DRIVER, GOOSE_DBSTRING, GOOSE_MIGRATION_DIR and GOOSE_TABLE, including loading from `.env` files. The CLI offers commands for creating migrations (`create`), applying them (`up`, `up-by-one`, `up-to`), rolling back (`down`, `down-to`, `reset`, `redo`), inspecting state (`status`, `version`) and validating files (`validate`, `fix`). A `-allow-missing` flag enables out-of-order migrations, and a hybrid versioning approach combining timestamps with sequential numbering is recommended for team workflows. SQL migrations use annotations such as `-- +goose Up` and `-- +goose Down`, with optional `NO TRANSACTION` and `StatementBegin`/`StatementEnd` markers for complex statements. Environment variable substitution can be enabled per file with `ENVSUB ON`/`ENVSUB OFF`. Go migrations are registered through `goose.AddMigration` and can be embedded into the binary using Go's embed package. Seeding data and embedded migrations are also supported.