Skip to main content

sova_scope/
entity.rs

1use sea_orm::entity::prelude::*;
2use serde::{Deserialize, Serialize};
3
4pub mod scope_membership {
5    use super::*;
6
7    #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
8    #[sea_orm(table_name = "scope_memberships")]
9    pub struct Model {
10        #[sea_orm(primary_key)]
11        pub id: i64,
12        pub scope_kind: String,
13        pub scope_id: i64,
14        pub user_id: i64,
15        pub role: String,
16    }
17
18    #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
19    pub enum Relation {}
20
21    impl ActiveModelBehavior for ActiveModel {}
22}
23
24#[cfg(feature = "invites")]
25pub mod scope_invitation {
26    use super::*;
27
28    #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
29    #[sea_orm(table_name = "scope_invitations")]
30    pub struct Model {
31        #[sea_orm(primary_key)]
32        pub id: i64,
33        pub scope_kind: String,
34        pub scope_id: i64,
35        pub email: String,
36        pub role: String,
37        pub invited_by: i64,
38        pub token: String,
39        pub status: String,
40        pub created_at: chrono::DateTime<chrono::Utc>,
41    }
42
43    #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
44    pub enum Relation {}
45
46    impl ActiveModelBehavior for ActiveModel {}
47}
48
49pub mod scope_membership_audit {
50    use super::*;
51
52    #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
53    #[sea_orm(table_name = "scope_membership_audit")]
54    pub struct Model {
55        #[sea_orm(primary_key)]
56        pub id: i64,
57        pub scope_kind: String,
58        pub scope_id: i64,
59        pub user_id: i64,
60        pub actor_id: Option<i64>,
61        pub action: String,
62        pub old_role: Option<String>,
63        pub new_role: Option<String>,
64        pub created_at: chrono::DateTime<chrono::Utc>,
65    }
66
67    #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
68    pub enum Relation {}
69
70    impl ActiveModelBehavior for ActiveModel {}
71}
72
73pub use scope_membership::Entity as ScopeMembership;
74pub use scope_membership_audit::Entity as ScopeMembershipAudit;
75
76#[cfg(feature = "invites")]
77pub use scope_invitation::Entity as ScopeInvitation;