Update database and RPC to provide configured feature flags
This commit is contained in:
parent
1c945a7521
commit
6fdf101745
14 changed files with 268 additions and 9 deletions
42
crates/collab/src/db/tables/user_feature.rs
Normal file
42
crates/collab/src/db/tables/user_feature.rs
Normal file
|
@ -0,0 +1,42 @@
|
|||
use sea_orm::entity::prelude::*;
|
||||
|
||||
use crate::db::{FlagId, UserId};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
|
||||
#[sea_orm(table_name = "user_features")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub user_id: UserId,
|
||||
#[sea_orm(primary_key)]
|
||||
pub feature_id: FlagId,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::feature_flag::Entity",
|
||||
from = "Column::FeatureId",
|
||||
to = "super::feature_flag::Column::Id"
|
||||
)]
|
||||
Flag,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::user::Entity",
|
||||
from = "Column::UserId",
|
||||
to = "super::user::Column::Id"
|
||||
)]
|
||||
User,
|
||||
}
|
||||
|
||||
impl Related<super::feature_flag::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Flag.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl Related<super::user::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::User.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
Loading…
Add table
Add a link
Reference in a new issue