From dc33fa8416ce6b447494c6efdf46518da37ac1cc Mon Sep 17 00:00:00 2001 From: Tolmachev Igor Date: Tue, 26 Aug 2025 21:13:53 +0900 Subject: Add database migration and entities --- entity/src/access_to_queue.rs | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 entity/src/access_to_queue.rs (limited to 'entity/src/access_to_queue.rs') diff --git a/entity/src/access_to_queue.rs b/entity/src/access_to_queue.rs new file mode 100644 index 0000000..9de03d5 --- /dev/null +++ b/entity/src/access_to_queue.rs @@ -0,0 +1,46 @@ +//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14 + +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] +#[sea_orm(table_name = "access_to_queue")] +pub struct Model { + #[sea_orm(primary_key, auto_increment = false)] + pub user_id: i64, + #[sea_orm(primary_key, auto_increment = false)] + pub queue_id: i64, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::queues::Entity", + from = "Column::QueueId", + to = "super::queues::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Queues, + #[sea_orm( + belongs_to = "super::users::Entity", + from = "Column::UserId", + to = "super::users::Column::Id", + on_update = "Cascade", + on_delete = "Cascade" + )] + Users, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Queues.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Users.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} -- cgit v1.2.3