Added command to add master password
This commit is contained in:
@ -1,12 +1,16 @@
|
||||
pub use sea_orm_migration::prelude::*;
|
||||
|
||||
mod m20220101_000001_create_table;
|
||||
mod m20230427_142510_change_password_hash_size;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigratorTrait for Migrator {
|
||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||
vec![Box::new(m20220101_000001_create_table::Migration)]
|
||||
vec![
|
||||
Box::new(m20220101_000001_create_table::Migration),
|
||||
Box::new(m20230427_142510_change_password_hash_size::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
44
migration/src/m20230427_142510_change_password_hash_size.rs
Normal file
44
migration/src/m20230427_142510_change_password_hash_size.rs
Normal file
@ -0,0 +1,44 @@
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[derive(Iden)]
|
||||
enum MasterPass {
|
||||
Table,
|
||||
#[iden = "password_hash"]
|
||||
PasswordHash,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
sea_query::Table::alter()
|
||||
.table(MasterPass::Table)
|
||||
.modify_column(
|
||||
ColumnDef::new(MasterPass::PasswordHash)
|
||||
.binary_len(64)
|
||||
.not_null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
sea_query::Table::alter()
|
||||
.table(MasterPass::Table)
|
||||
.modify_column(
|
||||
ColumnDef::new(MasterPass::PasswordHash)
|
||||
.binary_len(128)
|
||||
.not_null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user