use crate::migrator::m20241219_000001_create_ppl::Ppl;
use crate::migrator::m20241220_000004_create_sig_date::SigDate;
use sea_orm::sea_query::{ColumnDef, Table};
use sea_orm::{sea_query, DbErr, DeriveIden, ForeignKeyAction};
use sea_orm_migration::{MigrationName, MigrationTrait, SchemaManager};
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m_20241222_000008_create_traitdefaults"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(TraitDefault::Table)
.col(
ColumnDef::new(TraitDefault::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(TraitDefault::Key).string().not_null())
.col(ColumnDef::new(TraitDefault::Default).boolean().not_null())
.col(ColumnDef::new(TraitDefault::Enabled).boolean().not_null())
.col(ColumnDef::new(TraitDefault::IsDate).boolean().not_null())
.col(ColumnDef::new(TraitDefault::IsContact).boolean().not_null())
.col(ColumnDef::new(TraitDefault::Color).string().not_null())
.col(ColumnDef::new(TraitDefault::Symbol).string().not_null())
.col(ColumnDef::new(TraitDefault::DateIns).date().not_null())
.col(ColumnDef::new(TraitDefault::DateUp).date().not_null())
.to_owned(),
)
.await?;
// let foreign_key = sea_query::ForeignKey::create()
// .name("FK_character_font")
// .from(Tier::Table, Tier::PplId)
// .to(Ppl::Table, Ppl::Id)
// .on_delete(ForeignKeyAction::Cascade)
// .on_update(ForeignKeyAction::Cascade)
// .to_owned();
// manager.create_foreign_key(foreign_key).await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(TraitDefault::Table).to_owned())
.await
}
}
#[derive(DeriveIden)]
pub enum TraitDefault {
Table,
Id,
Key,
Default, // show in new forms / as-missing
Enabled, // actually-show-in-new-forms-or-not
IsDate, // map to a sig-date in the as-missings
IsContact, // map to a contact in the as-missings
Color,
Symbol,
DateIns,
DateUp,
}
⭐
Log in to mark this repository.
2.7 KiB · text
History
3eb5b38