Refinery
github.com
What it is
Refinery is a free, MIT-licensed SQL migration toolkit for Rust applications. It runs migrations against a database connection supplied by the application, either from embedded Rust code or through the refinery_cli command-line tool. Migrations can be SQL files or Rust modules whose migration function returns a String. Refinery records applied versions and metadata, then checks for missing or divergent migrations before running unapplied work. By default, each migration runs in its own transaction; grouped mode can place all migrations in one transaction. Migrations can also be built into a binary, so separate files are not needed at deployment. Listed drivers include postgres, tokio-postgres, mysql, mysql_async, rusqlite, and tiberius; SQLx can be used with a Config implementing Migrate. Driver selection is handled through features. Maintainers describe limited capacity to maintain additional drivers and point to external repositories, naming Klickhouse as an example. Refinery aims to support stable Rust, the previous Rust version, and nightly. To reverse a migration, users must create another migration with the reversing changes.
Spec sheet
- Purpose
- Refinery is a SQL migration toolkit for Rust that runs migrations on a provided database connection.Read 4 Oct 2026 · github.com
- License
- The project is licensed under the MIT License.Read 4 Oct 2026 · github.com
- Additional drivers
- The maintainers say limited bandwidth favors maintaining additional database drivers in external repositories; the README names Klickhouse as an example.Read 4 Oct 2026 · github.com
- Embedded migrations
- The project can bake migrations into a binary so no additional files are needed when deployed.Read 4 Oct 2026 · github.com
- Migration formats
- Migrations can be SQL files or Rust modules with a migration function that returns a String.Read 4 Oct 2026 · github.com
- Migration tracking
- Refinery records applied migration versions and metadata, then checks for divergent or missing migrations before executing unapplied ones.Read 4 Oct 2026 · github.com
- Rollback
- To undo a migration, users must create a new migration and write the changes that reverse it.Read 4 Oct 2026 · github.com
- Run modes
- Migrations can be embedded in Rust code or run through the refinery_cli command-line tool.Read 4 Oct 2026 · github.com
- Rust support
- The project aims to support stable Rust, the previous Rust version, and nightly.Read 4 Oct 2026 · github.com
- Source availability
- The project is published as a public GitHub repository.Read 4 Oct 2026 · github.com
- SQLx
- The README says SQLx can be used by providing a Config that implements Migrate.Read 4 Oct 2026 · github.com
- Supported drivers
- The README lists postgres, tokio-postgres, mysql, mysql_async, rusqlite, and tiberius as supported drivers.Read 4 Oct 2026 · github.com
- Transactions
- By default, each migration runs in its own transaction; grouped mode can wrap all migrations in one transaction.Read 4 Oct 2026 · github.com
- Version limit
- Migration versions default to signed 32-bit integers; the int8-versions feature enables 64-bit versions and must be enabled before use on a database.Read 4 Oct 2026 · github.com
Plans and prices
Strong points and limits
Strong points
- Free and MIT-licensed.
- Supports SQL files and Rust modules.
- Tracks migration versions and metadata.
- Can embed migrations in a binary.
- Supports per-migration or grouped transactions.
Limits
- Rollback requires a new reversing migration.
- Additional driver maintenance is limited.
- 64-bit versions require enabling a feature before database use.
Who it suits
It suits Rust developers who need database migrations in application code or a command-line workflow. It is also relevant to teams using one of the listed database drivers or SQLx through a compatible Config.
Verdict
Refinery provides migration tracking, transaction options, and embedded deployment for Rust projects. Driver support is selected through features, and undoing changes requires writing a new migration.
Where Specifiction places it
- Reverse Engineering Tools#32 of 737.6
- Database Migration Tools#20 of 327.6