Skip to main content

kellnr_entity/
oauth2_identity.rs

1//! `SeaORM` Entity for `OAuth2` identity
2
3use sea_orm::entity::prelude::*;
4
5#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
6#[sea_orm(table_name = "oauth2_identity")]
7pub struct Model {
8    #[sea_orm(primary_key)]
9    pub id: i64,
10    pub user_fk: i64,
11    #[sea_orm(column_type = "Text")]
12    pub provider_issuer: String,
13    #[sea_orm(column_type = "Text")]
14    pub subject: String,
15    #[sea_orm(column_type = "Text", nullable)]
16    pub email: Option<String>,
17    #[sea_orm(column_type = "Text")]
18    pub created: String,
19}
20
21#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
22pub enum Relation {
23    #[sea_orm(
24        belongs_to = "super::user::Entity",
25        from = "Column::UserFk",
26        to = "super::user::Column::Id",
27        on_update = "NoAction",
28        on_delete = "Cascade"
29    )]
30    User,
31}
32
33impl Related<super::user::Entity> for Entity {
34    fn to() -> RelationDef {
35        Relation::User.def()
36    }
37}
38
39impl ActiveModelBehavior for ActiveModel {}