diff options
| -rw-r--r-- | Cargo.toml | 1 | ||||
| -rw-r--r-- | entity/src/invite_tokens.rs | 32 | ||||
| -rw-r--r-- | entity/src/lib.rs | 1 | ||||
| -rw-r--r-- | entity/src/prelude.rs | 1 | ||||
| -rw-r--r-- | entity/src/queues.rs | 8 | ||||
| -rw-r--r-- | migration/src/m0_init_tables.rs | 27 |
6 files changed, 70 insertions, 0 deletions
| @@ -27,3 +27,4 @@ tracing-subscriber = "0.3.19" | |||
| 27 | utoipa = { version = "5.4.0", features = ["axum_extras", "chrono", "preserve_order", "preserve_path_order"] } | 27 | utoipa = { version = "5.4.0", features = ["axum_extras", "chrono", "preserve_order", "preserve_path_order"] } |
| 28 | utoipa-axum = "0.2.0" | 28 | utoipa-axum = "0.2.0" |
| 29 | utoipa-scalar = { version = "0.3.0", features = ["axum"] } | 29 | utoipa-scalar = { version = "0.3.0", features = ["axum"] } |
| 30 | uuid = { version = "1.18.1", features = ["v4", "serde"] } | ||
diff --git a/entity/src/invite_tokens.rs b/entity/src/invite_tokens.rs new file mode 100644 index 0000000..f239567 --- /dev/null +++ b/entity/src/invite_tokens.rs | |||
| @@ -0,0 +1,32 @@ | |||
| 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 = "invite_tokens")] | ||
| 7 | pub struct Model { | ||
| 8 | #[sea_orm(primary_key)] | ||
| 9 | pub id: i64, | ||
| 10 | pub token: Uuid, | ||
| 11 | pub queue_id: i64, | ||
| 12 | } | ||
| 13 | |||
| 14 | #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] | ||
| 15 | pub enum Relation { | ||
| 16 | #[sea_orm( | ||
| 17 | belongs_to = "super::queues::Entity", | ||
| 18 | from = "Column::QueueId", | ||
| 19 | to = "super::queues::Column::Id", | ||
| 20 | on_update = "Cascade", | ||
| 21 | on_delete = "Cascade" | ||
| 22 | )] | ||
| 23 | Queues, | ||
| 24 | } | ||
| 25 | |||
| 26 | impl Related<super::queues::Entity> for Entity { | ||
| 27 | fn to() -> RelationDef { | ||
| 28 | Relation::Queues.def() | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | impl ActiveModelBehavior for ActiveModel {} | ||
diff --git a/entity/src/lib.rs b/entity/src/lib.rs index 1ca05d6..389846a 100644 --- a/entity/src/lib.rs +++ b/entity/src/lib.rs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | pub mod prelude; | 3 | pub mod prelude; |
| 4 | 4 | ||
| 5 | pub mod access_to_queue; | 5 | pub mod access_to_queue; |
| 6 | pub mod invite_tokens; | ||
| 6 | pub mod queue_elements; | 7 | pub mod queue_elements; |
| 7 | pub mod queues; | 8 | pub mod queues; |
| 8 | pub mod sea_orm_active_enums; | 9 | pub mod sea_orm_active_enums; |
diff --git a/entity/src/prelude.rs b/entity/src/prelude.rs index 60f72f9..c4f6a2c 100644 --- a/entity/src/prelude.rs +++ b/entity/src/prelude.rs | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14 | 1 | //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.14 |
| 2 | 2 | ||
| 3 | pub use super::access_to_queue::Entity as AccessToQueue; | 3 | pub use super::access_to_queue::Entity as AccessToQueue; |
| 4 | pub use super::invite_tokens::Entity as InviteTokens; | ||
| 4 | pub use super::queue_elements::Entity as QueueElements; | 5 | pub use super::queue_elements::Entity as QueueElements; |
| 5 | pub use super::queues::Entity as Queues; | 6 | pub use super::queues::Entity as Queues; |
| 6 | pub use super::users::Entity as Users; | 7 | pub use super::users::Entity as Users; |
diff --git a/entity/src/queues.rs b/entity/src/queues.rs index 34b358a..c6116df 100644 --- a/entity/src/queues.rs +++ b/entity/src/queues.rs | |||
| @@ -15,6 +15,8 @@ pub struct Model { | |||
| 15 | pub enum Relation { | 15 | pub enum Relation { |
| 16 | #[sea_orm(has_many = "super::access_to_queue::Entity")] | 16 | #[sea_orm(has_many = "super::access_to_queue::Entity")] |
| 17 | AccessToQueue, | 17 | AccessToQueue, |
| 18 | #[sea_orm(has_many = "super::invite_tokens::Entity")] | ||
| 19 | InviteTokens, | ||
| 18 | #[sea_orm(has_many = "super::queue_elements::Entity")] | 20 | #[sea_orm(has_many = "super::queue_elements::Entity")] |
| 19 | QueueElements, | 21 | QueueElements, |
| 20 | #[sea_orm( | 22 | #[sea_orm( |
| @@ -33,6 +35,12 @@ impl Related<super::access_to_queue::Entity> for Entity { | |||
| 33 | } | 35 | } |
| 34 | } | 36 | } |
| 35 | 37 | ||
| 38 | impl Related<super::invite_tokens::Entity> for Entity { | ||
| 39 | fn to() -> RelationDef { | ||
| 40 | Relation::InviteTokens.def() | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 36 | impl Related<super::queue_elements::Entity> for Entity { | 44 | impl Related<super::queue_elements::Entity> for Entity { |
| 37 | fn to() -> RelationDef { | 45 | fn to() -> RelationDef { |
| 38 | Relation::QueueElements.def() | 46 | Relation::QueueElements.def() |
diff --git a/migration/src/m0_init_tables.rs b/migration/src/m0_init_tables.rs index 5bde7cc..ddbc0fb 100644 --- a/migration/src/m0_init_tables.rs +++ b/migration/src/m0_init_tables.rs | |||
| @@ -24,6 +24,14 @@ enum Queues { | |||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | #[derive(DeriveIden)] | 26 | #[derive(DeriveIden)] |
| 27 | enum InviteTokens { | ||
| 28 | Table, | ||
| 29 | Id, | ||
| 30 | Token, | ||
| 31 | QueueId, | ||
| 32 | } | ||
| 33 | |||
| 34 | #[derive(DeriveIden)] | ||
| 27 | enum AccessToQueue { | 35 | enum AccessToQueue { |
| 28 | Table, | 36 | Table, |
| 29 | UserId, | 37 | UserId, |
| @@ -97,6 +105,25 @@ impl MigrationTrait for Migration { | |||
| 97 | manager | 105 | manager |
| 98 | .create_table( | 106 | .create_table( |
| 99 | Table::create() | 107 | Table::create() |
| 108 | .table(InviteTokens::Table) | ||
| 109 | .if_not_exists() | ||
| 110 | .col(pk_auto(InviteTokens::Id).big_integer()) | ||
| 111 | .col(uuid(InviteTokens::Token)) | ||
| 112 | .col(big_integer(InviteTokens::QueueId)) | ||
| 113 | .foreign_key( | ||
| 114 | ForeignKey::create() | ||
| 115 | .from(InviteTokens::Table, InviteTokens::QueueId) | ||
| 116 | .to(Queues::Table, Queues::Id) | ||
| 117 | .on_delete(ForeignKeyAction::Cascade) | ||
| 118 | .on_update(ForeignKeyAction::Cascade), | ||
| 119 | ) | ||
| 120 | .to_owned(), | ||
| 121 | ) | ||
| 122 | .await?; | ||
| 123 | |||
| 124 | manager | ||
| 125 | .create_table( | ||
| 126 | Table::create() | ||
| 100 | .table(AccessToQueue::Table) | 127 | .table(AccessToQueue::Table) |
| 101 | .if_not_exists() | 128 | .if_not_exists() |
| 102 | .col(big_integer(AccessToQueue::UserId)) | 129 | .col(big_integer(AccessToQueue::UserId)) |
