2 unstable releases

0.2.0 Jun 25, 2022
0.1.0 Aug 17, 2020

#2425 in Database interfaces


Used in asyncmigrate-cli

Apache-2.0

33KB
748 lines

asyncmigrate

database migration with async support

Supported database

  • PostgreSQL

License

Apache License 2.0

SQL file name rule

Name of SQL files must be follow a rule in below.

VERSION__NAME.sql

VERSION must be a simple number and not include dot.

Example

use asyncmigrate::{MigrationError, Migration};
use rust_embed::RustEmbed;
 
#[derive(RustEmbed)]
#[folder = "schema/"]
struct Assets;
 
let mut connection = asyncmigrate::connect(
    "postgres://dbmigration-test:dbmigration-test@127.0.0.1:5432/dbmigration-test",
)
.await?;
 
let changeset = asyncmigrate::MigrationChangeSets::load_asset("default", Assets)?;

// Run migration
connection.migrate(&changeset, None).await?;
 
// Rollback
connection.rollback("default", None).await?;

lib.rs:

database migration with async support

Supported database

  • PostgreSQL

License

Apache License 2.0

Example

use asyncmigrate::{MigrationError, Migration};
use rust_embed::RustEmbed;

#[derive(RustEmbed)]
#[folder = "schema/"]
struct Assets;

let mut connection = asyncmigrate::connect(
    "postgres://dbmigration-test:dbmigration-test@127.0.0.1:5432/dbmigration-test",
)
.await?;

let changeset = asyncmigrate::MigrationChangeSets::load_asset("default", Assets)?;

// Run migration
connection.migrate(&changeset, None).await?;

// Rollback
connection.rollback("default", None).await?;

Dependencies

~6–22MB
~290K SLoC