migration!() { /* proc-macro */ }Expand description
Implements the Migration trait for some struct, given the tables that it
should manage.
ยงExample
struct MyMigration;
migration! { MyMigration => school, person}
// This is how you can use the migration. The up function creates all the tables in the correct
// order, and the down functions drops them.
MyMigration::up(...).await?;
MyMigration::down(...).await?;
#[derive(Table)]
struct Person {
id: i32,
name: String,
#[table(foreign_key(School))]
school_id: i32,
}
#[derive(Table)]
struct School {
id: i32,
name: String,
}Please note that the order of tables that are provided to this macro must be
in the correct order by which the tables should be created. For example in
the example above if we were to put the person table before the school
table we would get an error because person has a foreign key to school.