Freedom251 › Reverse Engineering Tools
Refinery

What Refinery is
Refinery is a free, MIT-licensed SQL migration toolkit for Rust applications. It runs migrations against a database connection provided by the application. Migrations can be embedded in Rust code or run with the refinery_cli command-line tool, and can be written as SQL files or Rust modules whose migration function returns a String. Refinery records applied migration 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 migration 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 that implements Migrate. Driver selection is handled through features. Refinery supports Linux, macOS, and Windows, and can be self-hosted. To undo a migration, users must create a new migration containing the reversing changes. The project aims to support stable Rust, the previous Rust version, and nightly.
Who it suits
Refinery suits Rust developers who want to manage SQL migrations through application code or a command-line tool. It supports several listed database drivers and self-hosted use.
What it does well
- Free and MIT-licensed.
- Supports SQL files and Rust migration modules.
- Can embed migrations in a binary.
- Tracks versions and checks for divergent migrations.
- Default transactions isolate each migration.
What to know first
- Rollback requires writing a new migration.
- 64-bit versions require enabling a feature before database use.
- Additional drivers may be maintained in external repositories.
Limits
Migration versions default to signed 32-bit integers; 64-bit versions require the int8-versions feature to be enabled before using the database. Reversing a migration requires a new migration with the reversing changes.
Plans
| Plan | Billed and limits | Price |
|---|---|---|
| Refinery | MIT-licensed SQL migration toolkit · database drivers must be selected as features | Free |
As github.com lists them, read 4 Oct 2026. The maker's own page has the final word.
Getting started
- Open the public GitHub project at https://github.com/rust-db/refinery.
- Select the database driver feature needed by the project.
- Choose SQL files or Rust modules for migration content.
- Run migrations through Rust code or the refinery_cli command-line tool.
- Optionally embed migrations in the application binary for deployment.
Verdict
Refinery offers Rust projects migration tracking, transaction handling, and embedded or command-line execution. Plan for rollback by writing a new migration, and check driver support and version settings for your setup.
Questions
How much does Refinery cost?
The listed plan is free. The pricing note identifies it as open source and MIT-licensed.
Which databases can it work with?
The README lists postgres, tokio-postgres, mysql, mysql_async, rusqlite, and tiberius drivers. SQLx can be used through a Config that implements Migrate.
How are migrations run?
They can be embedded in Rust code or run using the refinery_cli command-line tool. Migration content can be SQL files or Rust modules.
Does Refinery support rollback?
Yes, through a new migration that contains the changes needed to reverse an earlier migration.
Can I use Refinery in a self-hosted project?
Yes. Self-hosted use is listed, and migrations can be embedded into a binary for deployment.
What license does Refinery use?
Refinery is licensed under the MIT License and is published as a public GitHub repository.
Facts from Refinery's own pages
- Additional drivers
- The maintainers say limited bandwidth favors maintaining additional database drivers in external repositories; the README names Klickhouse as an example. · github.com, 4 Oct 2026
- Embedded migrations
- The project can bake migrations into a binary so no additional files are needed when deployed. · github.com, 4 Oct 2026
- License
- The project is licensed under the MIT License. · github.com, 4 Oct 2026
- Migration formats
- Migrations can be SQL files or Rust modules with a migration function that returns a String. · github.com, 4 Oct 2026
- Migration tracking
- Refinery records applied migration versions and metadata, then checks for divergent or missing migrations before executing unapplied ones. · github.com, 4 Oct 2026
- Purpose
- Refinery is a SQL migration toolkit for Rust that runs migrations on a provided database connection. · github.com, 4 Oct 2026
- Rollback
- To undo a migration, users must create a new migration and write the changes that reverse it. · github.com, 4 Oct 2026
- Run modes
- Migrations can be embedded in Rust code or run through the refinery_cli command-line tool. · github.com, 4 Oct 2026
- Rust support
- The project aims to support stable Rust, the previous Rust version, and nightly. · github.com, 4 Oct 2026
- Source availability
- The project is published as a public GitHub repository. · github.com, 4 Oct 2026
- SQLx
- The README says SQLx can be used by providing a Config that implements Migrate. · github.com, 4 Oct 2026
- Supported drivers
- The README lists postgres, tokio-postgres, mysql, mysql_async, rusqlite, and tiberius as supported drivers. · github.com, 4 Oct 2026
- Transactions
- By default, each migration runs in its own transaction; grouped mode can wrap all migrations in one transaction. · github.com, 4 Oct 2026
- 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. · github.com, 4 Oct 2026
Where Refinery stands on Freedom251
- Reverse Engineering Tools#26 of 73
- Database Migration Tools#15 of 32