Skip to main content

migration_set

Macro migration_set 

Source
macro_rules! migration_set {
    (module_id: $id:literal, $($m:ident,)*) => { ... };
}
Expand description

Declares a module’s migration set from one-file migrations.

Each migration lives in its own file under the module’s migrations/ directory, named m<name>.rs and exposing a pub struct Migration that implements Migration. This macro, invoked in the directory’s mod.rs, lists them in apply order: it declares each file as a submodule and generates the module’s MODULE_ID constant and its migrations() function returning the ordered MigrationSet. The list is the version history; append to its end, never reorder or rename a shipped entry.

The m prefix lets a name start with a digit (a bare 0001_... is not a valid Rust identifier). Scaffold new entries with lat make:migration.

The module_id is the module’s stable identity: a lowercase vendor.package code mirroring the crate name (crate acme-blog, id acme.blog). It namespaces applied-migration history, so keep it stable and never adopt another module’s.

ⓘ
// src/migrations/mod.rs
laterite_core::migration_set! {
    module_id: "acme.blog",
    m0001_create_posts,
    m0002_create_comments,
}