project.rs

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