Repolode
pressly

pressly/goose

A CLI and Go library for managing database schema changes through versioned SQL files or Go functions.

Stars
11,599
Forks
719
Open issues
145
Last commit
3 days ago

What is it?

Goose is a database migration tool that can be used as a command-line program or imported as a Go library. It manages schema changes as incremental migrations, each of which can be applied going up or rolled back going down, and tracks which versions have been applied in the database.

Migrations can be written as plain SQL files with up and down annotations, or as Go functions registered in your own binary. It supports a range of databases including Postgres, MySQL, MariaDB, SQLite, Spanner, ClickHouse, MSSQL and Vertica, and migration files can be embedded into a Go binary with the embed package. Other features include out-of-order migration handling, environment variable substitution in SQL files, and a fix command that converts timestamped migrations into sequential order for production.

Unused drivers can be excluded at build time with build tags to produce a smaller binary.

Key features

  • 01Runs SQL migrations and Go function migrations.
  • 02Supports Postgres, MySQL, MariaDB, SQLite, Spanner, ClickHouse, MSSQL and more.
  • 03Embeds migration files into Go binaries via embed.FS.
  • 04Supports out-of-order migrations and a fix command for sequential numbering.
  • 05Substitutes environment variables inside SQL migrations.

Use cases

  • Versioning the schema of a Go backend that runs against Postgres or MySQL.
  • Shipping database migrations inside a single deployable binary.
  • Running schema changes in CI so migrations are applied consistently across environments.

Quick start

  1. 1

    Install the goose CLI with Go

    go install github.com/pressly/goose/v3/cmd/goose@latest
  2. 2

    Check migration status against a SQLite database

    goose sqlite3 ./foo.db status
  3. 3

    Apply all available migrations

    goose sqlite3 ./foo.db up

Things to know

  • The README states the CLI needs a database driver and connection string for each command, so you must supply your own database.
  • Go is required to install the CLI via go install; Homebrew is offered only for macOS users.

Topics

FAQ

What is goose?
A CLI and Go library for managing database schema changes through versioned SQL files or Go functions. Goose is a database migration tool that can be used as a command-line program or imported as a Go library. It manages schema changes as incremental migrations, each of which can be applied going up or rolled back going down, and tracks which versions have been applied in the database.
Is goose free to use? What license does it have?
goose is open source under the Other license. Check the license terms before using it in commercial products.
Is goose still maintained?
Actively maintained. The last commit to goose was on Oct 17, 2026.
What can I use goose for?
Versioning the schema of a Go backend that runs against Postgres or MySQL. Shipping database migrations inside a single deployable binary. Running schema changes in CI so migrations are applied consistently across environments.
How do I install goose?
Install the goose CLI with Go: go install github.com/pressly/goose/v3/cmd/goose@latest Check migration status against a SQLite database: goose sqlite3 ./foo.db status Apply all available migrations: goose sqlite3 ./foo.db up
Where can I get goose?
The source code and installation instructions are on GitHub: https://github.com/pressly/goose

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects