1use super::{ProjectId, RoomId, UserId};
2use sea_orm::entity::prelude::*;
3
4#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
5#[sea_orm(table_name = "projects")]
6pub struct Model {
7 #[sea_orm(primary_key)]
8 pub id: ProjectId,
9 pub room_id: RoomId,
10 pub host_user_id: UserId,
11 pub host_connection_id: i32,
12}
13
14#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15pub enum Relation {
16 #[sea_orm(
17 belongs_to = "super::room::Entity",
18 from = "Column::RoomId",
19 to = "super::room::Column::Id"
20 )]
21 Room,
22 #[sea_orm(has_many = "super::worktree::Entity")]
23 Worktree,
24}
25
26impl Related<super::room::Entity> for Entity {
27 fn to() -> RelationDef {
28 Relation::Room.def()
29 }
30}
31
32impl Related<super::worktree::Entity> for Entity {
33 fn to() -> RelationDef {
34 Relation::Worktree.def()
35 }
36}
37
38impl ActiveModelBehavior for ActiveModel {}