[−][src]Macro refinery::include_migration_mods
include_migration_mods!() { /* proc-macro */ }
imports rust migration modules with migrations and inserts a function called runner that when called returns a Runner instance with the collected migration modules.
include_migration_mods
expects to be called from a mod.rs
file in directory called migrations below the src directory of your Rust project.
if you want the directory to have another name you have to call include_migration_mods
with it's path relative to the crate root.
In the future this will not be needed and include_migration_mods
will detect automatically from which module it is being called.
To be a valid migration module, it has to be named in the format V{1}__{2}.rs
where {1}
represents the migration version and {2}
the name.
For the name alphanumeric characters plus "_" are supported.
the migration module must have a function named migration that returns a String
Example using Barrel
// module named V1__add_persons_table.rs in src/db/migrations use barrel::backend::MySql; use barrel::{Migration, types}; pub fn migration() -> String { let mut m = Migration::new(); m.create_table("persons", |t| { t.add_column("id", types::primary()); t.add_column("name", types::varchar(255)); t.add_column("city", types::varchar(255)); }); m.make::<MySql>() }