Skip to content
Projects

iamsauravsharma/sqlx_migrator has 39 GitHub stars and 4 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-09 16:33 UTC. Last push 2026-10-23.

How these counts are measured

SQLX migration using Rust insted of SQL

What you can do

  • Migrations as Rust values with parents, replaces and run_before.
  • Operations as code, SQL strings or embedded SQL files.
  • CLI (apply, revert, redo, list, repair, prune) and RunReport.
  • Locking, failed migration tracking and hooks.

Measured star growth

in 24h
0
in 7 days
Update delayed
in 15 days
Update delayed
in 1 month
Update delayed

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

SQLX migrator

A Rust library for writing SQLX migrations using Rust instead of SQL.

License Crates Version Docs
License: MIT Crate Docs

Supported databases: PostgreSQL, SQLite and MySQL.

Features

  • Migrations as Rust values with parents, replaces and run_before.
  • Operations as code, SQL strings or embedded SQL files.
  • CLI (apply, revert, redo, list, repair, prune) and RunReport.
  • Locking, failed migration tracking and hooks.
  • Sync from other migration tools.

Installation

Enable postgres, mysql or sqlite (and json for CLI JSON output):

sqlx_migrator = { version = "0.20.0", features = ["postgres"] }

Quick start

use sqlx_migrator::migrator::{Migrator, Plan};
use sqlx_migrator::vec_box;

struct CreateSample;

// an operation is a `(up, down)` pair of SQL strings, or implement `Operation`
// for code
sqlx_migrator::postgres_migration!(
    CreateSample,
    "main",
    "create_sample",
    vec_box![],
    vec_box![(
        "CREATE TABLE sample (id INTEGER PRIMARY KEY, name TEXT)",
        "DROP TABLE sample"
    )]
);

#[tokio::main]
async fn main() {
    let pool = sqlx::PgPool::connect(&std::env::var("DATABASE_URL").unwrap())
        .await
        .unwrap();
    let mut conn = pool.acquire().await.unwrap();

    let mut migrator = Migrator::default();
    migrator.add_migration(Box::new(CreateSample)).unwrap();
    migrator.run(&mut *conn, &Plan::apply_all()).await.unwrap();
}

Documentation

See the crate docs for the guide, locking, CLI, hooks and sync.

Explore related projects