Compare commits
2 commits
3293bed51e
...
2f7e1c9924
Author | SHA1 | Date | |
---|---|---|---|
2f7e1c9924 | |||
4c30cd201e |
3 changed files with 13 additions and 2 deletions
|
@ -19,6 +19,7 @@ pub struct Model {
|
|||
pub name: String,
|
||||
pub email: String,
|
||||
pub hash: String,
|
||||
pub admin: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
||||
|
@ -27,6 +28,7 @@ pub enum Column {
|
|||
Name,
|
||||
Email,
|
||||
Hash,
|
||||
Admin,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
|
||||
|
@ -52,6 +54,7 @@ impl ColumnTrait for Column {
|
|||
Self::Name => ColumnType::String(None).def(),
|
||||
Self::Email => ColumnType::String(None).def().unique(),
|
||||
Self::Hash => ColumnType::String(None).def(),
|
||||
Self::Admin => ColumnType::Boolean.def(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ impl MigrationTrait for Migration {
|
|||
.col(ColumnDef::new(User::Name).string().not_null())
|
||||
.col(ColumnDef::new(User::Email).string().not_null().unique_key())
|
||||
.col(ColumnDef::new(User::Hash).string().not_null())
|
||||
.col(ColumnDef::new(User::Admin).boolean().not_null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
|
@ -40,4 +41,5 @@ enum User {
|
|||
Name,
|
||||
Email,
|
||||
Hash,
|
||||
Admin,
|
||||
}
|
||||
|
|
|
@ -17,8 +17,13 @@ impl MigrationTrait for Migration {
|
|||
.expect("Generating Admin Password Hash failed");
|
||||
let insert = Query::insert()
|
||||
.into_table(User::Table)
|
||||
.columns([User::Name, User::Email, User::Hash])
|
||||
.values_panic(["admin".into(), "admin".into(), hash.to_string().into()])
|
||||
.columns([User::Name, User::Email, User::Hash, User::Admin])
|
||||
.values_panic([
|
||||
"admin".into(),
|
||||
"admin".into(),
|
||||
hash.to_string().into(),
|
||||
true.into(),
|
||||
])
|
||||
.to_owned();
|
||||
|
||||
manager.exec_stmt(insert).await?;
|
||||
|
@ -36,4 +41,5 @@ enum User {
|
|||
Name,
|
||||
Email,
|
||||
Hash,
|
||||
Admin,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue