Embeddable migration management
Also see
migrant
CLI
migrant_lib
allows defining and embedding management of database migrations and
(connection) configuration 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
include_str!
).[a-z0-9-]
.fn(ConnConfig) -> 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(: migrantlib::ConnConfig) -> Result<(), Box
fn down(: migrantlib::ConnConfig) -> Result<(), Box
config.usemigrations(&[ migrantlib::FileMigration::withtag("create-users-table")? .up("migrations/embedded/createuserstable/up.sql")? .down("migrations/embedded/createuserstable/down.sql")? .boxed(), migrantlib::EmbeddedMigration::withtag("create-places-table")? .up(includestr!("../migrations/embedded/createplacestable/up.sql")) .down(includestr!("../migrations/embedded/createplacestable/down.sql")) .boxed(), migrantlib::FnMigration::with_tag("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.
See CONTRIBUTING
License: MIT