2 unstable releases
0.2.0 | Jun 25, 2022 |
---|---|
0.1.0 | Aug 17, 2020 |
#2540 in Database interfaces
33 downloads per month
Used in asyncmigrate-cli
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–20MB
~261K SLoC