talira

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.

  1. golang-migrate Database migrations as a CLI and Go library
  2. Atlas Database schema as code: plan, lint, test and apply schema migrations, like Terraform for databases
  3. sqldef Idempotent schema management in plain SQL for MySQL, PostgreSQL, SQLite and SQL Server
  4. pgroll Zero-downtime, reversible schema migrations for Postgres
  5. Reylo Import .sql files into TypeScript with types inferred from your live database, plus SQL-first migrations
  6. goose (database migrations) Database migration tool for SQL files and Go functions

Compare dbmate with the top 3