Embeddable migration management
Also see
migrant
CLI
migrant_lib
allows defining and embedding management of migrations in your compiled application.
Available Features:
| Feature | Backend |
|---------------|------------------------------|
| d-postgres
| Enable postgres connectivity |
| d-sqlite
| Enable sqlite connectivity |
| d-mysql
| Enable mysql connectivity |
| d-all
| Enable all backends |
Note: No features are enabled by default
[a-z0-9-]
.fn(DbConn) -> Result<(), Box<std::error::Error>>
.
See the embedded_programmable
example for a working sample of function migrations.d-postgres
/ d-sqlite
/ d-mysql
).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