mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-21 07:31:55 +00:00
chore: parent migrace
This commit is contained in:
parent
08fe562088
commit
3fb5a51cfb
5 changed files with 80 additions and 1 deletions
|
|
@ -5,3 +5,4 @@ pub mod prelude;
|
|||
|
||||
pub mod admin;
|
||||
pub mod candidate;
|
||||
pub mod parent;
|
||||
|
|
|
|||
23
entity/src/parent.rs
Normal file
23
entity/src/parent.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//! SeaORM Entity. Generated by sea-orm-codegen 0.10.0
|
||||
use sea_orm::entity::prelude::*;
|
||||
use chrono::{DateTime, Local};
|
||||
use rocket::serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[serde(crate = "rocket::serde")]
|
||||
#[sea_orm(table_name = "parent")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub application: i32,
|
||||
pub name: Option<String>,
|
||||
pub surname: Option<String>,
|
||||
pub telephone: Option<String>,
|
||||
pub email: Option<String>,
|
||||
pub created_at: DateTime<Local>,
|
||||
pub updated_at: DateTime<Local>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
|
@ -1,2 +1,3 @@
|
|||
pub use super::admin::Entity as Admin;
|
||||
pub use super::candidate::Entity as Candidate;
|
||||
pub use super::parent::Entity as Parent;
|
||||
|
|
|
|||
|
|
@ -2,12 +2,17 @@ pub use sea_orm_migration::prelude::*;
|
|||
|
||||
mod m20221024_111310_create_admin;
|
||||
mod m20221024_121621_create_candidate;
|
||||
mod m20221024_124701_create_parent;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigratorTrait for Migrator {
|
||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||
vec![Box::new(m20221024_111310_create_admin::Migration), Box::new(m20221024_121621_create_candidate::Migration)]
|
||||
vec![
|
||||
Box::new(m20221024_111310_create_admin::Migration),
|
||||
Box::new(m20221024_121621_create_candidate::Migration),
|
||||
Box::new(m20221024_124701_create_parent::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
49
migration/src/m20221024_124701_create_parent.rs
Normal file
49
migration/src/m20221024_124701_create_parent.rs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
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(Parent::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Parent::Application)
|
||||
.integer()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Parent::Name).string())
|
||||
.col(ColumnDef::new(Parent::Surname).string())
|
||||
.col(ColumnDef::new(Parent::Telephone).string())
|
||||
.col(ColumnDef::new(Parent::Email).string())
|
||||
.col(ColumnDef::new(Parent::CreatedAt).date_time().not_null())
|
||||
.col(ColumnDef::new(Parent::UpdatedAt).date_time().not_null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(Parent::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
/// Learn more at https://docs.rs/sea-query#iden
|
||||
#[derive(Iden)]
|
||||
enum Parent {
|
||||
Table,
|
||||
Application,
|
||||
Name,
|
||||
Surname,
|
||||
Telephone,
|
||||
Email,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
Loading…
Reference in a new issue