DEV.co
Open-Source Databases · rubenv

sql-migrate

sql-migrate is a Go-based database schema migration tool that supports multiple databases (SQLite, PostgreSQL, MySQL, MSSQL, Oracle) through both CLI and library interfaces. It allows embedding migrations into applications and supports atomic up/down migrations for rollback capability.

Source: GitHub — github.com/rubenv/sql-migrate
3.4k
GitHub stars
292
Forks
Go
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryrubenv/sql-migrate
Ownerrubenv
Primary languageGo
LicenseMIT — OSI-approved
Stars3.4k
Forks292
Open issues97
Latest releaseUnknown
Last updated2026-06-04
Sourcehttps://github.com/rubenv/sql-migrate

What sql-migrate is

Built on gorp and goose, sql-migrate provides SQL-defined migrations with special comment markers (-- +migrate Up/Down) parsed from files or memory sources. It tracks applied migrations in a database table and supports environment-specific configs with variable expansion for credentials.

Quickstart

Get the sql-migrate source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/rubenv/sql-migrate.gitcd sql-migrate# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Multi-Database Go Applications

Projects needing schema management across SQLite, PostgreSQL, MySQL, MSSQL, or Oracle can use a single tool with environment-specific migration directories and configs.

Embedded Migration Deployments

Applications embedding migrations via bindata or Go 1.18+ embed package can bundle schema changes with application releases, eliminating external migration file dependencies.

Library-Based Integration

Go services calling sql-migrate programmatically (via Exec API) can orchestrate migrations as part of initialization, useful for containerized or serverless deployments.

Implementation considerations

  • Migrations are raw SQL; no ORM abstraction, so database-specific syntax (e.g., MySQL parseTime flag, Oracle client setup) must be handled per dialect.
  • Migration ordering depends on timestamp-prefixed filenames; naming discipline and review process are critical to avoid out-of-order or conflicting changes.
  • The migrations tracking table (default gorp_migrations) must be writable and accessible; permissions and schema ownership should be verified in production.
  • Atomic per-migration transactions depend on database support; test rollback behavior under failure conditions before production deployment.
  • Environment variable substitution in datasource config (${VAR}) is supported; ensure secrets are never logged or committed to version control.

When to avoid it — and what to weigh

  • Non-Go Technology Stack — Projects in Python, Node.js, Java, or other languages should use ecosystem-native tools (Alembic, Flyway, Liquibase) rather than wrapping a Go binary.
  • Complex Cross-Database Compatibility — If migrations must run identically across databases with dialect-specific syntax, managing separate SQL files per dialect adds friction; unified abstraction tools may be preferable.
  • Stateful Rollback with Data Loss Risk — Down migrations that destructively drop tables or columns require careful testing; if downtime and data recovery procedures are not established, safer tools with dry-run validation are better.
  • Team Lacking SQL/Go Expertise — Teams unfamiliar with raw SQL or Go toolchain may struggle with migration authoring, debugging, and CI/CD integration without dedicated expertise.

License & commercial use

Released under the MIT License, a permissive OSI-approved license permitting commercial use, modification, and distribution with minimal restrictions.

MIT license permits commercial use without restriction. No proprietary clauses, GPL-like copyleft, or commercial licensing model detected. Standard commercial software development use is supported.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceModerate
DocumentationAdequate
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceMedium
Security considerations

Credentials can be passed via environment variables in datasource config, reducing hardcoding risk. No disclosure of security audit, vulnerability reporting process, or known CVEs in the provided data. Migration files contain raw SQL; injection risk depends on external input validation (not sql-migrate's responsibility). Test environment variable expansion and credential masking in logs.

Alternatives to consider

Flyway (Java, multi-language CLI)

Industry-standard with broader database support, commercial backing, and cloud integrations; better for polyglot teams or enterprises requiring vendor support.

Liquibase (Java, XML/YAML/SQL)

Offers change-log-based versioning, rollback simulation, and drift detection; steeper learning curve but more feature-rich for complex schemas.

goose (Pure Go, simpler syntax)

Similar scope to sql-migrate but earlier project (sql-migrate is based on it); consider if you prefer different API or community activity.

Software development agency

Build on sql-migrate with DEV.co software developers

Assess whether sql-migrate fits your schema management workflow. Review the GitHub repo, run test integrations, and validate multi-database support before adopting in production.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

sql-migrate FAQ

Can I use sql-migrate to migrate multiple databases in parallel?
The tool supports multiple database configs in one YAML file, but migrations are run sequentially per environment. Parallel execution across environments requires external orchestration (e.g., shell script, CI/CD pipeline).
What happens if a migration fails partway through?
Each migration runs in a single database transaction (if supported). If a statement fails, the transaction rolls back for that migration; previously applied migrations remain applied. The status command shows the state.
How do I handle data migrations (not just schema)?
Write SQL data-manipulation statements (INSERT, UPDATE, DELETE) in the Up and Down sections of migration files. This is straightforward but requires careful testing, especially for large datasets.
Can I embed migrations in a Docker image or Go binary?
Yes, using Go 1.18+ embed or older bindata approaches. The README shows AssetMigrationSource and HttpFileSystemMigrationSource for this pattern, enabling self-contained deployments.

Software development & web development with DEV.co

From first prototype to production, DEV.co delivers software development services around tools like sql-migrate. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across open-source databases and beyond.

Evaluate sql-migrate for your Go project

Assess whether sql-migrate fits your schema management workflow. Review the GitHub repo, run test integrations, and validate multi-database support before adopting in production.