mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-16 13:01:13 +00:00
chore: sample fill admin table
This commit is contained in:
parent
4493e408e3
commit
9dc330da6a
3 changed files with 34 additions and 0 deletions
|
|
@ -11,6 +11,8 @@ path = "src/lib.rs"
|
|||
[dependencies]
|
||||
rocket = { version = "0.5.0-rc.2" }
|
||||
async-std = { version = "^1", features = ["attributes", "tokio1"] }
|
||||
chrono = "0.4.22"
|
||||
portfolio-entity = { path = "../entity" }
|
||||
|
||||
[dependencies.sea-orm-migration]
|
||||
version = "^0.10.0"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ pub use sea_orm_migration::prelude::*;
|
|||
mod m20221024_111310_create_admin;
|
||||
mod m20221024_121621_create_candidate;
|
||||
mod m20221024_124701_create_parent;
|
||||
mod m20221024_134454_fill_admin;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
|
|
@ -13,6 +14,7 @@ impl MigratorTrait for Migrator {
|
|||
Box::new(m20221024_111310_create_admin::Migration),
|
||||
Box::new(m20221024_121621_create_candidate::Migration),
|
||||
Box::new(m20221024_124701_create_parent::Migration),
|
||||
Box::new(m20221024_134454_fill_admin::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
30
migration/src/m20221024_134454_fill_admin.rs
Normal file
30
migration/src/m20221024_134454_fill_admin.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use chrono::Local;
|
||||
use entity::admin;
|
||||
use sea_orm_migration::{prelude::*, sea_orm::{Set, ActiveModelTrait}};
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
let db = manager.get_connection();
|
||||
admin::ActiveModel {
|
||||
name: Set("Administrátor Pepa".to_owned()),
|
||||
public_key: Set("lorem ipsum".to_owned()),
|
||||
private_key_hash: Set("lorem ipsum".to_owned()),
|
||||
password_hash: Set("lorem ipsum".to_owned()),
|
||||
created_at: Set(Local::now().naive_local()),
|
||||
updated_at: Set(Local::now().naive_local()),
|
||||
..Default::default()
|
||||
}
|
||||
.insert(db)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue