Skip to main content

yauth_entity/
audit_log.rs

1use sea_orm::entity::prelude::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Serialize, Deserialize)]
5#[sea_orm(table_name = "yauth_audit_log")]
6pub struct Model {
7    #[sea_orm(primary_key, auto_increment = false)]
8    pub id: Uuid,
9    pub user_id: Option<Uuid>,
10    pub event_type: String,
11    #[sea_orm(column_type = "Json", nullable)]
12    pub metadata: Option<serde_json::Value>,
13    pub ip_address: Option<String>,
14    pub created_at: DateTimeWithTimeZone,
15}
16
17#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
18pub enum Relation {
19    #[sea_orm(
20        belongs_to = "super::users::Entity",
21        from = "Column::UserId",
22        to = "super::users::Column::Id"
23    )]
24    User,
25}
26
27impl Related<super::users::Entity> for Entity {
28    fn to() -> RelationDef {
29        Relation::User.def()
30    }
31}
32
33impl ActiveModelBehavior for ActiveModel {}