Embeddable migration management
migrant_lib
allows defining and embedding management of migration in your shipped app.
```rust
fn up(_: DbConn) -> Result<(), Box
fn down(_: DbConn) -> Result<(), Box
config.usemigrations(vec![ FileMigration::withtag("initial")? .up("migrations/initial/up.sql")? .down("migrations/initial/down.sql")? .boxed(), FileMigration::withtag("second")? .up("migrations/second/up.sql")? .down("migrations/second/down.sql")? .boxed(), FnMigration::withtag("custom")? .up(up) .down(down) .boxed(), ])?; ```
Migrations can be defined as files or functions. Migration files must exist at runtime.
Migration tags must all be unique. Function migrations must have the signature
fn(DbConn) -> Result<(), Box<std::error::Error>>
. See the
programmable example
for a working sample. When working with migrations, the respective database feature must
be enabled (postgresql
/ sqlite
). The entirety of the database-specific connection library will
be re-exported in the types
module.
Migrations management identical to the migrant
cli tool can also be embedded.
This method only supports file-base migrations generated by migrant_lib
(or migrant
cli). See the
embedded example
for a working sample.
License: MIT