A CLI and Go library for managing database schema changes through versioned SQL files or Go functions.
amacneil/dbmate
A lightweight, framework-agnostic command-line tool for managing plain SQL database migrations across teams and environments.
- Stars
- 7,465
- Forks
- 385
- Open issues
- 31
- Last commit
- 2 days ago
What is it?
Dbmate keeps a database schema in sync across developers and production servers by running timestamp-versioned SQL migration files. It ships as a standalone binary, so it can be used alongside Go, Node.js, Python, Ruby, PHP, Rust, C++, or any other stack that talks to a supported database.
Migrations are written as plain SQL with `migrate:up` and `migrate:down` sections in one file. Each migration runs inside a transaction by default, and applied versions are recorded in a `schema_migrations` table. Dbmate can also dump the resulting schema to a `schema.sql` file so schema changes show up as readable diffs in git.
The tool supports PostgreSQL, MySQL, MariaDB, SQLite, ClickHouse, BigQuery, and Spanner through its PostgreSQL interface. Connection details come from a `DATABASE_URL` variable or a `.env` file, and commands include create, drop, wait for the database to become ready, and rollback.
Key features
- 01Plain SQL migration files with up and down sections
- 02Timestamp-versioned migrations to avoid version conflicts between developers
- 03Migrations run atomically inside a transaction by default
- 04Dumps a schema.sql file for reviewing schema changes in version control
- 05Reads connection URLs from environment variables or a .env file
Use cases
- Keeping schema changes in sync across a team working on one application
- Managing migrations for several services written in different languages
- Creating and dropping test databases in CI before running a test suite
- Running migrations in production or in containers with a wait-for-database step
Quick start
- 1
Install via Homebrew on macOS
brew install dbmate - 2
Check the installed tool shows its help
dbmate --help - 3
Install via NPM as a dev dependency
npm install --save-dev dbmate
Things to know
- Requires a database connection URL, so you need a running database server such as PostgreSQL, MySQL or SQLite.
- PostgreSQL connections require TLS by default, so local setups often need sslmode=disable added.
Topics
FAQ
- What is dbmate?
- A lightweight, framework-agnostic command-line tool for managing plain SQL database migrations across teams and environments. Dbmate keeps a database schema in sync across developers and production servers by running timestamp-versioned SQL migration files. It ships as a standalone binary, so it can be used alongside Go, Node.js, Python, Ruby, PHP, Rust, C++, or any other stack that talks to a supported database.
- Is dbmate free to use? What license does it have?
- dbmate is open source under the MIT license. Check the license terms before using it in commercial products.
- Is dbmate still maintained?
- Actively maintained. The last commit to dbmate was on Oct 18, 2026.
- What can I use dbmate for?
- Keeping schema changes in sync across a team working on one application Managing migrations for several services written in different languages Creating and dropping test databases in CI before running a test suite Running migrations in production or in containers with a wait-for-database step
- How do I install dbmate?
- Install via Homebrew on macOS: brew install dbmate Check the installed tool shows its help: dbmate --help Install via NPM as a dev dependency: npm install --save-dev dbmate
- Where can I get dbmate?
- The source code and installation instructions are on GitHub: https://github.com/amacneil/dbmate
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A lightweight, headless TypeScript ORM for PostgreSQL, MySQL and SQLite that works across Node.js, Bun, Deno and edge runtimes.
AI-powered database client and MCP server for desktop and web, supporting Postgres, MySQL, MariaDB, SQL Server, ClickHouse and SQLite.
A free, local-first, AI-assisted database client and SQL workspace supporting 40+ databases across desktop, web, Docker and CLI.
Cross-platform SQL editor and database manager for Linux, macOS, and Windows, supporting MySQL, PostgreSQL, SQLite, SQL Server and many more.
Lightweight cross-platform database client for 100+ databases, with desktop, Docker, CLI, a built-in AI SQL assistant and an MCP server.