aboutsummaryrefslogtreecommitdiff
path: root/migration/src/m0_init_tables.rs
diff options
context:
space:
mode:
Diffstat (limited to 'migration/src/m0_init_tables.rs')
-rw-r--r--migration/src/m0_init_tables.rs17
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