💥 Replace migration_item! macro with migrations!
This commit is contained in:
parent
b934011516
commit
507015d5c9
5 changed files with 23 additions and 16 deletions
|
|
@ -31,11 +31,11 @@ impl ModuleTrait for Node {
|
|||
}
|
||||
|
||||
fn migrations(&self) -> Vec<MigrationItem> {
|
||||
vec![
|
||||
migration_item!(m20220316_000001_create_table_node_type),
|
||||
migration_item!(m20220316_000002_create_table_node),
|
||||
migration_item!(m20220316_000003_create_table_node_access),
|
||||
migration_item!(m20220316_000004_create_table_node_revision),
|
||||
migrations![
|
||||
m20220316_000001_create_table_node_type,
|
||||
m20220316_000002_create_table_node,
|
||||
m20220316_000003_create_table_node_access,
|
||||
m20220316_000004_create_table_node_revision,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ impl ModuleTrait for User {
|
|||
}
|
||||
|
||||
fn migrations(&self) -> Vec<MigrationItem> {
|
||||
vec![
|
||||
migration_item!(m20220312_000001_create_table_role),
|
||||
migration_item!(m20220312_000002_create_table_role_permission),
|
||||
migration_item!(m20220312_000003_create_table_user),
|
||||
migration_item!(m20220312_000004_create_table_user_role),
|
||||
migrations![
|
||||
m20220312_000001_create_table_role,
|
||||
m20220312_000002_create_table_role_permission,
|
||||
m20220312_000003_create_table_user,
|
||||
m20220312_000004_create_table_user_role,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::core::theme::ThemeRef;
|
|||
use crate::{service, util, Handle};
|
||||
|
||||
#[cfg(feature = "database")]
|
||||
use crate::db::MigrationItem;
|
||||
use crate::{db::MigrationItem, migrations};
|
||||
|
||||
pub type ModuleRef = &'static dyn ModuleTrait;
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ pub trait ModuleTrait: ModuleBase + Send + Sync {
|
|||
#[cfg(feature = "database")]
|
||||
#[allow(unused_variables)]
|
||||
fn migrations(&self) -> Vec<MigrationItem> {
|
||||
vec![]
|
||||
migrations![]
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
|
|
|
|||
|
|
@ -133,8 +133,15 @@ macro_rules! pub_migration {
|
|||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! migration_item {
|
||||
( $migration_module:ident ) => {{
|
||||
Box::new(migration::$migration_module::Migration)
|
||||
macro_rules! migrations {
|
||||
() => {
|
||||
Vec::<MigrationItem>::new()
|
||||
};
|
||||
( $($migration_module:ident),+ $(,)? ) => {{
|
||||
let mut m = Vec::<MigrationItem>::new();
|
||||
$(
|
||||
m.push(Box::new(migration::$migration_module::Migration));
|
||||
)*
|
||||
m
|
||||
}};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ pub use crate::locale::*;
|
|||
pub use crate::datetime::*;
|
||||
|
||||
#[cfg(feature = "database")]
|
||||
pub use crate::{db, db::*, migration_item, pub_migration};
|
||||
pub use crate::{db, db::*, migrations, pub_migration};
|
||||
|
||||
pub use crate::service;
|
||||
pub use crate::service::HttpMessage;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue