#sql #migration

pg-migrator

Macro free Postgres migration tool for Rust Postgres and Tokio Postgres

3 unstable releases

0.2.1 Sep 9, 2023
0.1.1 Sep 8, 2023
0.1.0 Sep 8, 2023

#2615 in Database interfaces

MIT license

14KB
291 lines

Pg-Migrator

Rust Docs.rs

Pg-Migrator is a simple, macro-free, crate for running migrations on Postgres databases.

Usage

Quickstart

For rust-postgres use:

[dependencies]
pg-migrator = { version = "0.1.0", features = ["postgres"] }

For tokio-postgres use:

[dependencies]
pg-migrator = { version = "0.1.0", features = ["tokio-postgres"] }

Then, create your Postgres/Tokio Postgres connection as always and run the migrations:

use postgres::{Client, NoTls, Error};

fn main() {
    let mut client = Client::connect("postgresql://postgres:postgres@localhost/library", NoTls).unwrap();

    PostgresMigrator::new("./migrations")
        .migrate(&mut conn)
        .unwrap();
}

Dependencies

~3–14MB
~163K SLoC