billing_preference.rs

 1use crate::db::{BillingPreferencesId, UserId};
 2use sea_orm::entity::prelude::*;
 3
 4#[derive(Clone, Debug, Default, PartialEq, Eq, DeriveEntityModel)]
 5#[sea_orm(table_name = "billing_preferences")]
 6pub struct Model {
 7    #[sea_orm(primary_key)]
 8    pub id: BillingPreferencesId,
 9    pub created_at: DateTime,
10    pub user_id: UserId,
11    pub max_monthly_llm_usage_spending_in_cents: i32,
12    pub model_request_overages_enabled: bool,
13    pub model_request_overages_spend_limit_in_cents: i32,
14}
15
16#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
17pub enum Relation {
18    #[sea_orm(
19        belongs_to = "super::user::Entity",
20        from = "Column::UserId",
21        to = "super::user::Column::Id"
22    )]
23    User,
24}
25
26impl Related<super::user::Entity> for Entity {
27    fn to() -> RelationDef {
28        Relation::User.def()
29    }
30}
31
32impl ActiveModelBehavior for ActiveModel {}