A lightweight, framework-agnostic database migration tool for plain SQL migrations
open sourceMITfree
dbmate is a standalone command-line tool that runs plain SQL migrations, so it works the same with Go, Node.js, Python, Ruby, PHP, Rust or any other language. Migrations are timestamp-versioned, so developers don't collide on version numbers, and each runs in a transaction. It supports PostgreSQL, MySQL, MariaDB, SQLite, ClickHouse, BigQuery and Spanner, reads the connection URL from DATABASE_URL or a .env file, can create and drop databases, waits for the database to come up, and writes a schema.sql file to diff schema changes in git. It's a single binary, and also a Go library that can embed migrations.
Problems it solves
- a simple framework-agnostic tool to run plain SQL migrations for any language
- run SQL migrations from a single binary without pulling in an ORM
- keep a schema.sql file in git that shows every schema change
Features
- Plain SQL migrations
- Timestamp-versioned migrations
- Each migration in a transaction
- Rollback
- schema.sql export
- Create and drop databases
- Wait for the database
- Go library with embedded migrations
- Docker image
Alternatives
The same job
These do what dbmate does.
- golang-migrate Database migrations as a CLI and Go library
- Atlas Database schema as code: plan, lint, test and apply schema migrations, like Terraform for databases
- sqldef Idempotent schema management in plain SQL for MySQL, PostgreSQL, SQLite and SQL Server
- pgroll Zero-downtime, reversible schema migrations for Postgres
- Reylo Import .sql files into TypeScript with types inferred from your live database, plus SQL-first migrations
- goose (database migrations) Database migration tool for SQL files and Go functions
