Portfolio/entity/src/session.rs
Vojtěch Jungmann dd7386882b
Merge pull request #18 from EETagent/small_dependencies_refactoring
Small dependencies refactoring
2022-10-29 13:02:58 +02:00

32 lines
806 B
Rust

use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "session")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub user_id: i32,
pub ip_address: String,
pub created_at: DateTime,
pub expires_at: DateTime,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::candidate::Entity",
from = "Column::UserId",
to = "super::candidate::Column::Application",
on_update = "Cascade",
on_delete = "Cascade"
)]
Candidate,
}
impl Related<super::candidate::Entity> for Entity {
fn to() -> RelationDef {
Relation::Candidate.def()
}
}
impl ActiveModelBehavior for ActiveModel {}