shield_sea_orm/entities/
user.rs

1//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.2
2
3use sea_orm::entity::prelude::*;
4use serde::{Deserialize, Serialize};
5
6#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
7#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema), schema(as = User))]
8#[sea_orm(table_name = "user")]
9pub struct Model {
10    #[sea_orm(primary_key, auto_increment = false)]
11    pub id: Uuid,
12    pub created_at: chrono::DateTime<chrono::FixedOffset>,
13    pub updated_at: chrono::DateTime<chrono::FixedOffset>,
14    #[cfg(not(feature = "entity"))]
15    #[sea_orm(column_type = "Text")]
16    pub name: String,
17    #[cfg(feature = "entity")]
18    pub entity_id: Uuid,
19}
20
21#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
22pub enum Relation {
23    #[cfg(feature = "entity")]
24    #[sea_orm(
25        belongs_to = "super::entity::Entity",
26        from = "Column::EntityId",
27        to = "super::entity::Column::Id",
28        on_update = "Cascade",
29        on_delete = "Cascade"
30    )]
31    Entity,
32    #[cfg(not(feature = "entity"))]
33    #[sea_orm(has_many = "super::email_address::Entity")]
34    EmailAddress,
35    #[cfg(feature = "method-oauth")]
36    #[sea_orm(has_many = "super::oauth_provider_connection::Entity")]
37    OauthProviderConnection,
38    #[cfg(feature = "method-oidc")]
39    #[sea_orm(has_many = "super::oidc_provider_connection::Entity")]
40    OidcProviderConnection,
41}
42
43#[cfg(feature = "entity")]
44impl Related<super::entity::Entity> for Entity {
45    fn to() -> RelationDef {
46        Relation::Entity.def()
47    }
48}
49
50#[cfg(not(feature = "entity"))]
51impl Related<super::email_address::Entity> for Entity {
52    fn to() -> RelationDef {
53        Relation::EmailAddress.def()
54    }
55}
56
57#[cfg(feature = "method-oauth")]
58impl Related<super::oauth_provider_connection::Entity> for Entity {
59    fn to() -> RelationDef {
60        Relation::OauthProviderConnection.def()
61    }
62}
63
64#[cfg(feature = "method-oidc")]
65impl Related<super::oidc_provider_connection::Entity> for Entity {
66    fn to() -> RelationDef {
67        Relation::OidcProviderConnection.def()
68    }
69}
70
71impl ActiveModelBehavior for ActiveModel {}