1use crate::db::{BillingCustomerId, UserId};
2use sea_orm::entity::prelude::*;
3
4/// A billing customer.
5#[derive(Clone, Debug, Default, PartialEq, Eq, DeriveEntityModel)]
6#[sea_orm(table_name = "billing_customers")]
7pub struct Model {
8 #[sea_orm(primary_key)]
9 pub id: BillingCustomerId,
10 pub user_id: UserId,
11 pub stripe_customer_id: String,
12 pub has_overdue_invoices: bool,
13 pub created_at: DateTime,
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 #[sea_orm(has_many = "super::billing_subscription::Entity")]
25 BillingSubscription,
26}
27
28impl Related<super::user::Entity> for Entity {
29 fn to() -> RelationDef {
30 Relation::User.def()
31 }
32}
33
34impl Related<super::billing_subscription::Entity> for Entity {
35 fn to() -> RelationDef {
36 Relation::BillingSubscription.def()
37 }
38}
39
40impl ActiveModelBehavior for ActiveModel {}