gitdataai/libs/models/users/user_billing_history.rs

41 lines
1.1 KiB
Rust

use crate::{DateTimeUtc, UserId};
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
/// Billing transaction history for a user's personal account.
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "user_billing_history")]
pub struct Model {
#[sea_orm(primary_key)]
pub uid: Uuid,
#[sea_orm(column_name = "user_uuid")]
pub user: UserId,
#[sea_orm(column_type = "Decimal(Some((20, 4)))")]
pub amount: Decimal,
#[sea_orm(column_type = "Text")]
pub currency: String,
#[sea_orm(column_type = "Text")]
pub reason: String,
#[sea_orm(column_type = "JsonBinary", nullable)]
pub extra: Option<Json>,
pub created_at: DateTimeUtc,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "crate::users::user::Entity",
from = "Column::User",
to = "crate::users::user::Column::Uid"
)]
User,
}
impl Related<crate::users::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()
}
}
impl ActiveModelBehavior for ActiveModel {}