Added command to add master password

This commit is contained in:
2023-04-27 17:40:49 +03:00
parent e8fc43f9ad
commit 3f8adb96f9
6 changed files with 192 additions and 4 deletions

View File

@ -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),
]
}
}

View 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
}
}