Actualiza formato del código aplicando cargo fmt
This commit is contained in:
parent
4b5caf06a7
commit
e6ea59785e
75 changed files with 1069 additions and 1160 deletions
|
|
@ -14,51 +14,57 @@ pub_migration!(Migration);
|
|||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager.create_table(Table::create()
|
||||
.table(Role::Table)
|
||||
.if_not_exists()
|
||||
.col(ColumnDef::new(Role::Rid)
|
||||
.unsigned()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key()
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Role::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Role::Rid)
|
||||
.unsigned()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Role::Name)
|
||||
.string_len(64)
|
||||
.not_null()
|
||||
.unique_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Role::Weight)
|
||||
.integer()
|
||||
.not_null()
|
||||
.default(10),
|
||||
)
|
||||
// INDEXES.
|
||||
.index(
|
||||
Index::create()
|
||||
.name("weight-name")
|
||||
.col(Role::Weight)
|
||||
.col(Role::Name),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.col(ColumnDef::new(Role::Name)
|
||||
.string_len(64)
|
||||
.not_null()
|
||||
.unique_key()
|
||||
)
|
||||
.col(ColumnDef::new(Role::Weight)
|
||||
.integer()
|
||||
.not_null()
|
||||
.default(10)
|
||||
)
|
||||
// INDEXES.
|
||||
.index(Index::create()
|
||||
.name("weight-name")
|
||||
.col(Role::Weight)
|
||||
.col(Role::Name)
|
||||
)
|
||||
.to_owned()
|
||||
)
|
||||
.await?;
|
||||
.await?;
|
||||
|
||||
// Built-in roles.
|
||||
app::db::exec::<InsertStatement>(Query::insert()
|
||||
.into_table(Role::Table)
|
||||
.columns(vec![Role::Name, Role::Weight])
|
||||
.values_panic(vec!["anonymous".into(), "1".into()])
|
||||
.values_panic(vec!["authenticated".into(), "2".into()])
|
||||
.values_panic(vec!["administrator".into(), "3".into()])
|
||||
app::db::exec::<InsertStatement>(
|
||||
Query::insert()
|
||||
.into_table(Role::Table)
|
||||
.columns(vec![Role::Name, Role::Weight])
|
||||
.values_panic(vec!["anonymous".into(), "1".into()])
|
||||
.values_panic(vec!["authenticated".into(), "2".into()])
|
||||
.values_panic(vec!["administrator".into(), "3".into()]),
|
||||
)
|
||||
.await.map(|_| ())
|
||||
.await
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager.drop_table(Table::drop()
|
||||
.table(Role::Table)
|
||||
.to_owned()
|
||||
)
|
||||
.await
|
||||
manager
|
||||
.drop_table(Table::drop().table(Role::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue