text/x-rust
•
928 B
•
36 lines
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};
use super::common::AccessType;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "access_tokens")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub created_at: Option<DateTimeWithTimeZone>,
pub project: Uuid,
pub access_type: AccessType,
#[sea_orm(unique)]
pub token: Uuid,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::project::Entity",
from = "Column::Project",
to = "super::project::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
Project,
}
impl Related<super::project::Entity> for Entity {
fn to() -> RelationDef {
Relation::Project.def()
}
}
impl ActiveModelBehavior for ActiveModel {}