feat: simplify database scheme
This commit is contained in:
parent
fcb3a18416
commit
9963cff724
15 changed files with 96 additions and 370 deletions
35
server/src/db/entities/package_related.rs
Normal file
35
server/src/db/entities/package_related.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.1
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "package_related")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub package_id: i32,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub r#type: crate::db::PackageRelatedEnum,
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::package::Entity",
|
||||
from = "Column::PackageId",
|
||||
to = "super::package::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Package,
|
||||
}
|
||||
|
||||
impl Related<super::package::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Package.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue