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 pub host_connection_epoch: Uuid,
13}
14
15#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
16pub enum Relation {
17 #[sea_orm(
18 belongs_to = "super::user::Entity",
19 from = "Column::HostUserId",
20 to = "super::user::Column::Id"
21 )]
22 HostUser,
23 #[sea_orm(
24 belongs_to = "super::room::Entity",
25 from = "Column::RoomId",
26 to = "super::room::Column::Id"
27 )]
28 Room,
29 #[sea_orm(has_many = "super::worktree::Entity")]
30 Worktrees,
31 #[sea_orm(has_many = "super::project_collaborator::Entity")]
32 Collaborators,
33 #[sea_orm(has_many = "super::language_server::Entity")]
34 LanguageServers,
35}
36
37impl Related<super::user::Entity> for Entity {
38 fn to() -> RelationDef {
39 Relation::HostUser.def()
40 }
41}
42
43impl Related<super::room::Entity> for Entity {
44 fn to() -> RelationDef {
45 Relation::Room.def()
46 }
47}
48
49impl Related<super::worktree::Entity> for Entity {
50 fn to() -> RelationDef {
51 Relation::Worktrees.def()
52 }
53}
54
55impl Related<super::project_collaborator::Entity> for Entity {
56 fn to() -> RelationDef {
57 Relation::Collaborators.def()
58 }
59}
60
61impl Related<super::language_server::Entity> for Entity {
62 fn to() -> RelationDef {
63 Relation::LanguageServers.def()
64 }
65}
66
67impl ActiveModelBehavior for ActiveModel {}