macro_rules! migration {
(
$type:ident,
$name:literal,
up: |$up_schema:ident| $up:block,
down: |$down_schema:ident| $down:block $(,)?
) => { ... };
}Expand description
Define a migration without writing the pinned-future boilerplate.
ⓘ
migration!(
CreateUsersTable,
"2026_08_29_000001_create_users_table",
up: |schema| {
schema.create("users", |t| { t.id(); t.string("name"); }).await
},
down: |schema| { schema.drop("users").await },
);The bodies are blocks rather than closures on purpose: a closure returning a future that borrows its argument cannot express the lifetime that relationship needs, and the error it produces is unreadable.