mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-05 11:00:56 +00:00
chore: candidate migrace
This commit is contained in:
parent
884bc3dea7
commit
c42a52e863
1 changed files with 73 additions and 0 deletions
73
migration/src/m20221024_121621_create_candidate.rs
Normal file
73
migration/src/m20221024_121621_create_candidate.rs
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(Candidate::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(Candidate::Application)
|
||||||
|
.integer()
|
||||||
|
.not_null()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(Candidate::Code).string().not_null())
|
||||||
|
.col(ColumnDef::new(Candidate::Name).string())
|
||||||
|
.col(ColumnDef::new(Candidate::Surname).string())
|
||||||
|
.col(ColumnDef::new(Candidate::BirthSurname).string())
|
||||||
|
.col(ColumnDef::new(Candidate::Birthplace).string())
|
||||||
|
.col(ColumnDef::new(Candidate::Birthdate).date())
|
||||||
|
.col(ColumnDef::new(Candidate::Address).string())
|
||||||
|
.col(ColumnDef::new(Candidate::Telephone).string())
|
||||||
|
.col(ColumnDef::new(Candidate::Citizenship).string())
|
||||||
|
.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::PersonalIdentificationNumberHash).text())
|
||||||
|
.col(ColumnDef::new(Candidate::PublicKey).string().not_null())
|
||||||
|
.col(ColumnDef::new(Candidate::PrivateKey).string().not_null())
|
||||||
|
.col(ColumnDef::new(Candidate::CreatedAt).date_time().not_null())
|
||||||
|
.col(ColumnDef::new(Candidate::UpdatedAt).date_time().not_null())
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(Candidate::Table).to_owned())
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Learn more at https://docs.rs/sea-query#iden
|
||||||
|
#[derive(Iden)]
|
||||||
|
enum Candidate {
|
||||||
|
Table,
|
||||||
|
Application,
|
||||||
|
Code,
|
||||||
|
Name,
|
||||||
|
Surname,
|
||||||
|
BirthSurname,
|
||||||
|
Birthplace,
|
||||||
|
Birthdate,
|
||||||
|
Address,
|
||||||
|
Telephone,
|
||||||
|
Citizenship,
|
||||||
|
Email,
|
||||||
|
Sex,
|
||||||
|
Study,
|
||||||
|
PersonalIdentificationNumber,
|
||||||
|
PersonalIdentificationNumberHash,
|
||||||
|
PublicKey,
|
||||||
|
PrivateKey,
|
||||||
|
CreatedAt,
|
||||||
|
UpdatedAt,
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue