migrant_lib
Embeddable migration management
migrant_lib
allows defining and embedding management of migrations in your compiled application.
- Migrations can be defined as files or functions.
- File migrations can be either read from files at runtime or embedded in your executable at compile time.
- Migration tags must all be unique and may only contain the characters
[a-z0-9-]
. - Function migrations must have the signature
fn(DbConn) -> Result<(), Box<std::error::Error>>
. See the embedded_programmable example for a working sample of function migrations. - When working with embedded and function migrations, the respective database feature must be
enabled (
postgresql
/sqlite
). - When database features are enabled, the entirety of the database-specific connection library will
be re-exported in the
types
module.
.use_migrations?;
config
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 migrant_cli_compatible example for a working sample.
License: MIT