Crates.io | asyncmigrate |
lib.rs | asyncmigrate |
version | 0.2.0 |
source | src |
created_at | 2020-08-17 14:10:55.844663 |
updated_at | 2022-06-25 04:56:50.371243 |
description | database migration with async support |
homepage | https://github.com/informationsea/asyncmigrate-rs |
repository | https://github.com/informationsea/asyncmigrate-rs |
max_upload_size | |
id | 277513 |
size | 32,223 |
database migration with async support
Apache License 2.0
Name of SQL files must be follow a rule in below.
VERSION__NAME.sql
VERSION
must be a simple number and not include dot.
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?;