shield_sea_orm/entities/
email_address.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 = EmailAddress))]
8#[sea_orm(table_name = "email_address")]
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    #[sea_orm(unique)]
15    pub email: String,
16    pub is_primary: bool,
17    pub is_verified: bool,
18    pub verification_token: Option<String>,
19    pub verification_token_expired_at: Option<chrono::DateTime<chrono::FixedOffset>>,
20    pub verified_at: Option<chrono::DateTime<chrono::FixedOffset>>,
21    #[cfg(feature = "entity")]
22    pub entity_id: Uuid,
23    #[cfg(not(feature = "entity"))]
24    pub user_id: Uuid,
25}
26
27#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
28pub enum Relation {
29    #[cfg(feature = "entity")]
30    #[sea_orm(
31        belongs_to = "super::entity::Entity",
32        from = "Column::EntityId",
33        to = "super::entity::Column::Id",
34        on_update = "Cascade",
35        on_delete = "Cascade"
36    )]
37    Entity,
38    #[cfg(not(feature = "entity"))]
39    #[sea_orm(
40        belongs_to = "super::user::Entity",
41        from = "Column::UserId",
42        to = "super::user::Column::Id",
43        on_update = "Cascade",
44        on_delete = "Cascade"
45    )]
46    User,
47}
48
49#[cfg(feature = "entity")]
50impl Related<super::entity::Entity> for Entity {
51    fn to() -> RelationDef {
52        Relation::Entity.def()
53    }
54}
55
56#[cfg(not(feature = "entity"))]
57impl Related<super::user::Entity> for Entity {
58    fn to() -> RelationDef {
59        Relation::User.def()
60    }
61}
62
63impl ActiveModelBehavior for ActiveModel {}