lf9-pgg/crates/backend/src/db/entity/group.rs
2025-06-11 14:48:16 +02:00

42 lines
1.1 KiB
Rust

//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.7
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "group")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
#[sea_orm(primary_key, auto_increment = false)]
pub project_id: Uuid,
pub name: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::project::Entity",
from = "Column::ProjectId",
to = "super::project::Column::Id",
on_update = "Cascade",
on_delete = "Cascade"
)]
Project,
#[sea_orm(has_many = "super::user_group_project::Entity")]
UserGroupProject,
}
impl Related<super::project::Entity> for Entity {
fn to() -> RelationDef {
Relation::Project.def()
}
}
impl Related<super::user_group_project::Entity> for Entity {
fn to() -> RelationDef {
Relation::UserGroupProject.def()
}
}
impl ActiveModelBehavior for ActiveModel {}