diff options
| author | Tolmachev Igor <me@igorek.dev> | 2025-09-27 13:48:50 +0300 |
|---|---|---|
| committer | Tolmachev Igor <me@igorek.dev> | 2025-09-27 13:48:50 +0300 |
| commit | 413708f2baa3987b4b8c7c727eeee8cfd8d59f73 (patch) | |
| tree | b108339ad2b2c78b9b01c8c413ab54ab1e673168 /migration/src | |
| parent | 974c8c586e1182d502a2c30ba8b622c0b4033937 (diff) | |
| download | queue_server-413708f2baa3987b4b8c7c727eeee8cfd8d59f73.tar.gz queue_server-413708f2baa3987b4b8c7c727eeee8cfd8d59f73.zip | |
Fix invite tokens models
Diffstat (limited to 'migration/src')
| -rw-r--r-- | migration/src/m0_init_tables.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/migration/src/m0_init_tables.rs b/migration/src/m0_init_tables.rs index ddbc0fb..5e9a621 100644 --- a/migration/src/m0_init_tables.rs +++ b/migration/src/m0_init_tables.rs | |||
| @@ -29,6 +29,8 @@ enum InviteTokens { | |||
| 29 | Id, | 29 | Id, |
| 30 | Token, | 30 | Token, |
| 31 | QueueId, | 31 | QueueId, |
| 32 | Name, | ||
| 33 | IsRevoked, | ||
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | #[derive(DeriveIden)] | 36 | #[derive(DeriveIden)] |
| @@ -36,6 +38,7 @@ enum AccessToQueue { | |||
| 36 | Table, | 38 | Table, |
| 37 | UserId, | 39 | UserId, |
| 38 | QueueId, | 40 | QueueId, |
| 41 | InviteTokenId, | ||
| 39 | } | 42 | } |
| 40 | 43 | ||
| 41 | #[derive(DeriveIden)] | 44 | #[derive(DeriveIden)] |
| @@ -117,6 +120,8 @@ impl MigrationTrait for Migration { | |||
| 117 | .on_delete(ForeignKeyAction::Cascade) | 120 | .on_delete(ForeignKeyAction::Cascade) |
| 118 | .on_update(ForeignKeyAction::Cascade), | 121 | .on_update(ForeignKeyAction::Cascade), |
| 119 | ) | 122 | ) |
| 123 | .col(string(InviteTokens::Name)) | ||
| 124 | .col(boolean(InviteTokens::IsRevoked).default(false)) | ||
| 120 | .to_owned(), | 125 | .to_owned(), |
| 121 | ) | 126 | ) |
| 122 | .await?; | 127 | .await?; |
| @@ -142,6 +147,14 @@ impl MigrationTrait for Migration { | |||
| 142 | .on_delete(ForeignKeyAction::Cascade) | 147 | .on_delete(ForeignKeyAction::Cascade) |
| 143 | .on_update(ForeignKeyAction::Cascade), | 148 | .on_update(ForeignKeyAction::Cascade), |
| 144 | ) | 149 | ) |
| 150 | .col(big_integer(AccessToQueue::InviteTokenId)) | ||
| 151 | .foreign_key( | ||
| 152 | ForeignKey::create() | ||
| 153 | .from(AccessToQueue::Table, AccessToQueue::InviteTokenId) | ||
| 154 | .to(InviteTokens::Table, InviteTokens::Id) | ||
| 155 | .on_delete(ForeignKeyAction::Cascade) | ||
| 156 | .on_update(ForeignKeyAction::Cascade), | ||
| 157 | ) | ||
| 145 | .primary_key( | 158 | .primary_key( |
| 146 | Index::create() | 159 | Index::create() |
| 147 | .col(AccessToQueue::UserId) | 160 | .col(AccessToQueue::UserId) |
| @@ -209,6 +222,10 @@ impl MigrationTrait for Migration { | |||
| 209 | .await?; | 222 | .await?; |
| 210 | 223 | ||
| 211 | manager | 224 | manager |
| 225 | .drop_table(Table::drop().table(InviteTokens::Table).to_owned()) | ||
| 226 | .await?; | ||
| 227 | |||
| 228 | manager | ||
| 212 | .drop_table(Table::drop().table(AccessToQueue::Table).to_owned()) | 229 | .drop_table(Table::drop().table(AccessToQueue::Table).to_owned()) |
| 213 | .await?; | 230 | .await?; |
| 214 | 231 | ||
