refinery
Powerful SQL migration toolkit for Rust, embeddable in your app or run via CLI.
Repository Health
Technical Analysis
refinery runs versioned database migrations for Rust applications, either embedded directly in your binary via the embed_migrations! macro or driven from the command line through the companion refinery_cli crate. It supports Postgres, MySQL, SQLite, and MSSQL through pluggable driver features, with both synchronous and async runners.
What You Get
- embed_migrations! macro to bake versioned migrations into your compiled binary
- Sync and async Runner APIs (run/run_async) across postgres, mysql, rusqlite, and tiberius drivers
- SQL-file or Rust-function migrations with strict (V) or non-contiguous (U) versioning
- A separate refinery_cli crate for running migrations from the command line via DATABASE_URL
Common Use Cases
- Applying schema migrations automatically at application startup for Postgres/MySQL/SQLite/MSSQL
- Running database migrations from CI/CD pipelines via the refinery CLI against a DATABASE_URL
- Coordinating schema changes across a team using non-contiguous migration versioning to avoid merge conflicts
- Baking migrations into a single deployable binary so no separate migration files are needed at runtime
Under The Hood
Architecture - The workspace separates the driver-agnostic engine (refinery_core, with traits/mod.rs and traits/async.rs defining the sync/async Migrate traits that each database driver implements), the embed_migrations!/refinery::config macros (refinery_macros), the public facade crate (refinery) that re-exports both behind feature flags, and a standalone refinery_cli binary crate that wraps the same core engine behind a command-line interface reading a Config/DATABASE_URL. Tech Stack - Rust 2018/2021 across the workspace (MSRV 1.85 pinned at the workspace level), with optional driver dependencies gated per feature (postgres, tokio-postgres, mysql, mysql_async, rusqlite, tiberius), toml/serde for config parsing, and dev-dependencies including barrel for schema-generation examples and tokio/futures for async test coverage. Code Quality - Tests span the core engine and CLI (assert_cmd/predicates used to test CLI behavior end-to-end), with async coverage exercised via tokio across supported drivers; the project has run for 8+ years with sustained community contribution (87 contributors) though the maintainers have explicitly scoped down driver support to keep bandwidth manageable, pushing new drivers to external repos. API Design - The API centers on a small Runner type obtained from migrations::runner() with .run()/.run_async() entry points per driver feature, plus the embed_migrations! macro for compile-time embedding — deliberately narrow, following the Flyway migration philosophy (no auto-generated rollback/undo migrations).
Used by 3 apps in this directory
Arroyo
Data Engineering · Analytics
A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.
Huly Platform
Project Management · Team Chat · Collaboration
Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.
PeerDB
Data Engineering · Databases
Postgres-native ETL that streams change data capture in real time to Snowflake, BigQuery, ClickHouse, S3, and Kafka — up to 10x faster than general-purpose pipelines, managed through a familiar Postgres SQL interface.