Manage database schema changes in a Go web app, tracking which migrations have been applied across dev, staging, and production.
Roll back a botched database change with a single goose down command.
Write migrations as Go functions when plain SQL is not expressive enough for complex data transformations.
Sync database schemas across a team where different developers create migrations on different branches.
Goose is a tool for managing database migrations, the controlled process of updating or rolling back the structure of a database as a software project evolves. It is written in Go and works as both a command-line program you can run directly and as a library you can import into your own Go code. When a project's database needs a new table, a changed column, or some removed data, developers write migration files that describe those changes in sequence. Goose keeps track of which migrations have already been applied, runs the ones that have not, and can reverse them if needed. Migration files can be written as plain SQL statements or as Go functions, giving teams flexibility in how they express changes. Goose works with many database systems, including Postgres, MySQL, SQLite, SQL Server, ClickHouse, and several others. Installing it takes one command using the standard Go toolchain, and macOS users can also install it through Homebrew. The commands you use most often are: up to apply all pending migrations, down to roll back the most recent one, status to see which migrations have run and which are still pending, and create to generate a new migration file with a timestamp in the name. The tool also offers up-to and down-to for landing at a specific version, and reset to roll back everything at once. A notable feature is support for out-of-order migrations, which means Goose can apply migrations correctly even when different team members created them in different orders across different environments. SQL migration files can also reference environment variables, which is useful when connection strings or schema names differ between development and production.
← pressly on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.