1use sea_orm::entity::prelude::*;
2
3use crate::db::{FlagId, UserId};
4
5#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
6#[sea_orm(table_name = "user_features")]
7pub struct Model {
8 #[sea_orm(primary_key)]
9 pub user_id: UserId,
10 #[sea_orm(primary_key)]
11 pub feature_id: FlagId,
12}
13
14#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15pub enum Relation {
16 #[sea_orm(
17 belongs_to = "super::feature_flag::Entity",
18 from = "Column::FeatureId",
19 to = "super::feature_flag::Column::Id"
20 )]
21 Flag,
22 #[sea_orm(
23 belongs_to = "super::user::Entity",
24 from = "Column::UserId",
25 to = "super::user::Column::Id"
26 )]
27 User,
28}
29
30impl Related<super::feature_flag::Entity> for Entity {
31 fn to() -> RelationDef {
32 Relation::Flag.def()
33 }
34}
35
36impl Related<super::user::Entity> for Entity {
37 fn to() -> RelationDef {
38 Relation::User.def()
39 }
40}
41
42impl ActiveModelBehavior for ActiveModel {}