diff options
| author | Tolmachev Igor <me@igorek.dev> | 2025-08-26 21:13:53 +0900 |
|---|---|---|
| committer | Tolmachev Igor <me@igorek.dev> | 2025-08-26 21:13:53 +0900 |
| commit | dc33fa8416ce6b447494c6efdf46518da37ac1cc (patch) | |
| tree | 6bf069f70c953f14b3a7e84ed4a7bbcde3de7012 /entity/src/queues.rs | |
| parent | 9cb5689c87978c4e05e87f631ebf92a626d583b0 (diff) | |
| download | queue_server-dc33fa8416ce6b447494c6efdf46518da37ac1cc.tar.gz queue_server-dc33fa8416ce6b447494c6efdf46518da37ac1cc.zip | |
Add database migration and entities
Diffstat (limited to 'entity/src/queues.rs')
| -rw-r--r-- | entity/src/queues.rs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/entity/src/queues.rs b/entity/src/queues.rs new file mode 100644 index 0000000..34b358a --- /dev/null +++ b/entity/src/queues.rs | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14 | ||
| 2 | |||
| 3 | use sea_orm::entity::prelude::*; | ||
| 4 | |||
| 5 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] | ||
| 6 | #[sea_orm(table_name = "queues")] | ||
| 7 | pub struct Model { | ||
| 8 | #[sea_orm(primary_key)] | ||
| 9 | pub id: i64, | ||
| 10 | pub owner_id: i64, | ||
| 11 | pub name: String, | ||
| 12 | } | ||
| 13 | |||
| 14 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] | ||
| 15 | pub enum Relation { | ||
| 16 | #[sea_orm(has_many = "super::access_to_queue::Entity")] | ||
| 17 | AccessToQueue, | ||
| 18 | #[sea_orm(has_many = "super::queue_elements::Entity")] | ||
| 19 | QueueElements, | ||
| 20 | #[sea_orm( | ||
| 21 | belongs_to = "super::users::Entity", | ||
| 22 | from = "Column::OwnerId", | ||
| 23 | to = "super::users::Column::Id", | ||
| 24 | on_update = "Cascade", | ||
| 25 | on_delete = "Cascade" | ||
| 26 | )] | ||
| 27 | Users, | ||
| 28 | } | ||
| 29 | |||
| 30 | impl Related<super::access_to_queue::Entity> for Entity { | ||
| 31 | fn to() -> RelationDef { | ||
| 32 | Relation::AccessToQueue.def() | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | impl Related<super::queue_elements::Entity> for Entity { | ||
| 37 | fn to() -> RelationDef { | ||
| 38 | Relation::QueueElements.def() | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | impl Related<super::users::Entity> for Entity { | ||
| 43 | fn to() -> RelationDef { | ||
| 44 | super::access_to_queue::Relation::Users.def() | ||
| 45 | } | ||
| 46 | fn via() -> Option<RelationDef> { | ||
| 47 | Some(super::access_to_queue::Relation::Queues.def().rev()) | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | impl ActiveModelBehavior for ActiveModel {} | ||
