macro_rules! migration {
(
$struct_name:ident,
$name:expr,
up = $up:expr,
down = $down:expr $(,)?
) => { ... };
}Expand description
Closure-style migration — Laravel’s
Schema::create('posts', function (Blueprint $t) { ... }) ported to Rust.
Expands to a unit struct + Migration impl + inventory::submit! —
the same machinery #[derive(Migration)] produces, just spelled in
six lines instead of twenty.
Usage:
ⓘ
use anvilforge::prelude::*;
migration!(CreatePostsTable, "2026_05_20_create_posts_table",
up = |s| {
s.create("posts", |t| {
t.id();
t.string("title").not_null();
t.text("body").not_null();
t.timestamps();
});
},
down = |s| {
s.drop_if_exists("posts");
},
);The struct name is explicit (mirrors Laravel’s class name) so the inventory registration stays deterministic and rollback diagnostics can name the migration in panics/errors.