Skip to main content

yauth_entity/
passwords.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_passwords")]
6pub struct Model {
7    #[sea_orm(primary_key, auto_increment = false)]
8    pub user_id: Uuid,
9    pub password_hash: String,
10}
11
12#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
13pub enum Relation {
14    #[sea_orm(
15        belongs_to = "super::users::Entity",
16        from = "Column::UserId",
17        to = "super::users::Column::Id"
18    )]
19    User,
20}
21
22impl Related<super::users::Entity> for Entity {
23    fn to() -> RelationDef {
24        Relation::User.def()
25    }
26}
27
28impl ActiveModelBehavior for ActiveModel {}