Embeddable migration management
migrant_lib
allows defining and embedding management of migrations in your compiled application.
[a-z0-9-]
.fn(DbConn) -> Result<(), Box<std::error::Error>>
.
See the embedded_programmable
example for a working sample of function migrations.postgresql
/ sqlite
).types
module.```rust
fn up(_: DbConn) -> Result<(), Box
fn down(_: DbConn) -> Result<(), Box
config.usemigrations(vec![ FileMigration::withtag("initial")? .up("migrations/embedded/initial/up.sql")? .down("migrations/embedded/initial/down.sql")? .boxed(), EmbeddedMigration::withtag("second")? .up(includestr!("../migrations/embedded/second/up.sql")) .down(includestr!("../migrations/embedded/second/down.sql")) .boxed(), FnMigration::withtag("custom")? .up(up) .down(down) .boxed(), ])?; ```
Migrations management identical to the migrant
cli tool can also be embedded.
This method only supports file-based migrations and those migration files must be generated by migrant_lib::new
(or the migrant
cli). This is required because migration order is implied by file names which must follow
a specific format and contain a valid timestamp.
See the migrantclicompatible example for a working sample.
License: MIT