Portfolio/migration/src/m20221024_124701_create_parent.rs
2022-12-05 16:20:52 +01:00

55 lines
1.6 KiB
Rust

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::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(
ColumnDef::new(Parent::Application)
.integer()
.not_null()
)
.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
}
}
#[derive(Iden)]
pub enum Parent {
Id,
Table,
Application,
Name,
Surname,
Telephone,
Email,
CreatedAt,
UpdatedAt,
}