From d0825b80d530260feadb37f1da7406c0bc383453 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Sun, 30 Oct 2022 13:06:45 +0100 Subject: [PATCH] feat: PIdN not null --- core/src/mutation.rs | 4 ++-- entity/src/candidate.rs | 2 +- migration/Cargo.toml | 4 +++- migration/src/m20221024_121621_create_candidate.rs | 2 +- migration/src/main.rs | 6 ++++++ 5 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 migration/src/main.rs diff --git a/core/src/mutation.rs b/core/src/mutation.rs index b83ee97..c759322 100644 --- a/core/src/mutation.rs +++ b/core/src/mutation.rs @@ -26,7 +26,7 @@ impl Mutation { candidate::ActiveModel { application: Set(application_id), - personal_identification_number: Set(Some(encrypted_personal_id_number)), + personal_identification_number: Set(encrypted_personal_id_number), code: Set(hashed_password), public_key: Set(pubkey), private_key: Set(encrypted_priv_key), @@ -98,7 +98,7 @@ mod tests { let db = get_memory_sqlite_connection().await; let form = serde_json::from_value(json!({ - "application": 5555555, + "application_id": 5555555, })).unwrap(); let plain_text_password = "test".to_string(); diff --git a/entity/src/candidate.rs b/entity/src/candidate.rs index 75b42cd..9800dc2 100644 --- a/entity/src/candidate.rs +++ b/entity/src/candidate.rs @@ -19,7 +19,7 @@ pub struct Model { pub email: Option, pub sex: Option, pub study: Option, - pub personal_identification_number: Option, + pub personal_identification_number: String, #[sea_orm(column_type = "Text", nullable)] pub personal_identification_number_hash: Option, pub public_key: String, diff --git a/migration/Cargo.toml b/migration/Cargo.toml index 794151d..673784b 100644 --- a/migration/Cargo.toml +++ b/migration/Cargo.toml @@ -9,10 +9,12 @@ name = "migration" path = "src/lib.rs" [dependencies] +tokio = { version = "^1.21", features = ["macros"] } + serde = { version = "^1.0", features = ["derive"] } chrono = "^0.4" portfolio-entity = { path = "../entity" } [dependencies.sea-orm-migration] version = "^0.10" -features = [ "runtime-tokio-native-tls", "sqlx-postgres", "sqlx-sqlite"] +features = [ "runtime-tokio-native-tls", "sqlx-postgres", "sqlx-sqlite"] \ No newline at end of file diff --git a/migration/src/m20221024_121621_create_candidate.rs b/migration/src/m20221024_121621_create_candidate.rs index 929838b..5483c3a 100644 --- a/migration/src/m20221024_121621_create_candidate.rs +++ b/migration/src/m20221024_121621_create_candidate.rs @@ -30,7 +30,7 @@ impl MigrationTrait for Migration { .col(ColumnDef::new(Candidate::Email).string()) .col(ColumnDef::new(Candidate::Sex).string()) .col(ColumnDef::new(Candidate::Study).string()) - .col(ColumnDef::new(Candidate::PersonalIdentificationNumber).string()) + .col(ColumnDef::new(Candidate::PersonalIdentificationNumber).string().not_null()) .col(ColumnDef::new(Candidate::PersonalIdentificationNumberHash).text()) .col(ColumnDef::new(Candidate::PublicKey).string().not_null()) .col(ColumnDef::new(Candidate::PrivateKey).string().not_null()) diff --git a/migration/src/main.rs b/migration/src/main.rs new file mode 100644 index 0000000..85be8cc --- /dev/null +++ b/migration/src/main.rs @@ -0,0 +1,6 @@ +use sea_orm_migration::prelude::*; + +#[tokio::main] +async fn main() { + cli::run_cli(migration::Migrator).await; +} \ No newline at end of file