@@ -217,7 +217,33 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
217
217
SELECT concat(' ALTER TABLE ' , table_schema,' .' ,table_name,' DROP FOREIGN KEY ' , constraint_name, ' ;' )
218
218
FROM information_schema .table_constraints
219
219
WHERE constraint_type= ' FOREIGN KEY'
220
- AND table_schema = DATABASE();
220
+ AND table_schema = DATABASE()
221
+ AND table_name in (
222
+ ' all_auth_recipe_users' ,
223
+ ' dashboard_user_sessions' ,
224
+ ' dashboard_users' ,
225
+ ' emailpassword_pswd_reset_tokens' ,
226
+ ' emailpassword_users' ,
227
+ ' emailverification_tokens' ,
228
+ ' emailverification_verified_emails' ,
229
+ ' jwt_signing_keys' ,
230
+ ' key_value' ,
231
+ ' passwordless_codes' ,
232
+ ' passwordless_devices' ,
233
+ ' passwordless_users' ,
234
+ ' role_permissions' ,
235
+ ' roles' ,
236
+ ' session_access_token_signing_keys' ,
237
+ ' session_info' ,
238
+ ' thirdparty_users' ,
239
+ ' totp_used_codes' ,
240
+ ' totp_user_devices' ,
241
+ ' totp_users' ,
242
+ ' user_last_active' ,
243
+ ' user_metadata' ,
244
+ ' user_roles' ,
245
+ ' userid_mapping'
246
+ );
221
247
222
248
DECLARE CONTINUE handler for NOT found SET done = true;
223
249
OPEN dropCur;
@@ -240,7 +266,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
240
266
CLOSE dropCur;
241
267
END
242
268
243
- -- -
269
+ --
244
270
245
271
CREATE PROCEDURE st_drop_all_pkeys()
246
272
BEGIN
@@ -250,7 +276,33 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
250
276
SELECT concat(' ALTER TABLE ' , table_schema,' .' ,table_name,' DROP PRIMARY KEY ' , ' ;' )
251
277
FROM information_schema .table_constraints
252
278
WHERE constraint_type= ' PRIMARY KEY'
253
- AND table_schema = DATABASE();
279
+ AND table_schema = DATABASE()
280
+ AND table_name in (
281
+ ' all_auth_recipe_users' ,
282
+ ' dashboard_user_sessions' ,
283
+ ' dashboard_users' ,
284
+ ' emailpassword_pswd_reset_tokens' ,
285
+ ' emailpassword_users' ,
286
+ ' emailverification_tokens' ,
287
+ ' emailverification_verified_emails' ,
288
+ ' jwt_signing_keys' ,
289
+ ' key_value' ,
290
+ ' passwordless_codes' ,
291
+ ' passwordless_devices' ,
292
+ ' passwordless_users' ,
293
+ ' role_permissions' ,
294
+ ' roles' ,
295
+ ' session_access_token_signing_keys' ,
296
+ ' session_info' ,
297
+ ' thirdparty_users' ,
298
+ ' totp_used_codes' ,
299
+ ' totp_user_devices' ,
300
+ ' totp_users' ,
301
+ ' user_last_active' ,
302
+ ' user_metadata' ,
303
+ ' user_roles' ,
304
+ ' userid_mapping'
305
+ );
254
306
255
307
DECLARE CONTINUE handler for NOT found SET done = true;
256
308
OPEN dropCur;
@@ -273,7 +325,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
273
325
CLOSE dropCur;
274
326
END
275
327
276
- -- -
328
+ --
277
329
278
330
CREATE PROCEDURE st_drop_all_keys()
279
331
BEGIN
@@ -283,7 +335,33 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
283
335
SELECT concat(' ALTER TABLE ' , table_schema,' .' ,table_name,' DROP INDEX ' , constraint_name, ' ;' )
284
336
FROM information_schema .table_constraints
285
337
WHERE constraint_type= ' UNIQUE'
286
- AND table_schema = DATABASE();
338
+ AND table_schema = DATABASE()
339
+ AND table_name in (
340
+ ' all_auth_recipe_users' ,
341
+ ' dashboard_user_sessions' ,
342
+ ' dashboard_users' ,
343
+ ' emailpassword_pswd_reset_tokens' ,
344
+ ' emailpassword_users' ,
345
+ ' emailverification_tokens' ,
346
+ ' emailverification_verified_emails' ,
347
+ ' jwt_signing_keys' ,
348
+ ' key_value' ,
349
+ ' passwordless_codes' ,
350
+ ' passwordless_devices' ,
351
+ ' passwordless_users' ,
352
+ ' role_permissions' ,
353
+ ' roles' ,
354
+ ' session_access_token_signing_keys' ,
355
+ ' session_info' ,
356
+ ' thirdparty_users' ,
357
+ ' totp_used_codes' ,
358
+ ' totp_user_devices' ,
359
+ ' totp_users' ,
360
+ ' user_last_active' ,
361
+ ' user_metadata' ,
362
+ ' user_roles' ,
363
+ ' userid_mapping'
364
+ );
287
365
288
366
DECLARE CONTINUE handler for NOT found SET done = true;
289
367
OPEN dropCur;
@@ -306,7 +384,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
306
384
CLOSE dropCur;
307
385
END
308
386
309
- -- -
387
+ --
310
388
311
389
CREATE PROCEDURE st_drop_all_indexes()
312
390
BEGIN
@@ -315,7 +393,34 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
315
393
DECLARE dropCur CURSOR for
316
394
SELECT DISTINCT concat(' ALTER TABLE ' , table_schema, ' .' , table_name, ' DROP INDEX ' , index_name, ' ;' )
317
395
FROM information_schema .statistics
318
- WHERE NON_UNIQUE = 1 AND table_schema = database();
396
+ WHERE NON_UNIQUE = 1
397
+ AND table_schema = database()
398
+ AND table_name in (
399
+ ' all_auth_recipe_users' ,
400
+ ' dashboard_user_sessions' ,
401
+ ' dashboard_users' ,
402
+ ' emailpassword_pswd_reset_tokens' ,
403
+ ' emailpassword_users' ,
404
+ ' emailverification_tokens' ,
405
+ ' emailverification_verified_emails' ,
406
+ ' jwt_signing_keys' ,
407
+ ' key_value' ,
408
+ ' passwordless_codes' ,
409
+ ' passwordless_devices' ,
410
+ ' passwordless_users' ,
411
+ ' role_permissions' ,
412
+ ' roles' ,
413
+ ' session_access_token_signing_keys' ,
414
+ ' session_info' ,
415
+ ' thirdparty_users' ,
416
+ ' totp_used_codes' ,
417
+ ' totp_user_devices' ,
418
+ ' totp_users' ,
419
+ ' user_last_active' ,
420
+ ' user_metadata' ,
421
+ ' user_roles' ,
422
+ ' userid_mapping'
423
+ );
319
424
320
425
DECLARE CONTINUE handler for NOT found SET done = true;
321
426
OPEN dropCur;
@@ -338,7 +443,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
338
443
CLOSE dropCur;
339
444
END
340
445
341
- -- -
446
+ --
342
447
343
448
CREATE PROCEDURE st_add_column_if_not_exists(
344
449
IN p_table_name varchar (50 ),
@@ -390,7 +495,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
390
495
INSERT IGNORE INTO apps (app_id, created_at_time)
391
496
VALUES (' public' , 0 );
392
497
393
- -- ----------------------------------------------------------
498
+ --
394
499
395
500
CREATE TABLE IF NOT EXISTS tenants (
396
501
app_id VARCHAR (64 ) NOT NULL DEFAULT ' public' ,
@@ -408,7 +513,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
408
513
INSERT IGNORE INTO tenants (app_id, tenant_id, created_at_time)
409
514
VALUES (' public' , ' public' , 0 );
410
515
411
- -- ----------------------------------------------------------
516
+ --
412
517
413
518
CALL st_add_column_if_not_exists(' key_value' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
414
519
CALL st_add_column_if_not_exists(' key_value' , ' tenant_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
@@ -420,7 +525,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
420
525
ADD FOREIGN KEY (app_id, tenant_id)
421
526
REFERENCES tenants (app_id, tenant_id) ON DELETE CASCADE ;
422
527
423
- -- ----------------------------------------------------------
528
+ --
424
529
425
530
CREATE TABLE IF NOT EXISTS app_id_to_user_id (
426
531
app_id VARCHAR (64 ) NOT NULL DEFAULT ' public' ,
@@ -439,7 +544,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
439
544
SELECT user_id, recipe_id
440
545
FROM all_auth_recipe_users;
441
546
442
- -- ----------------------------------------------------------
547
+ --
443
548
444
549
CALL st_add_column_if_not_exists(' all_auth_recipe_users' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
445
550
CALL st_add_column_if_not_exists(' all_auth_recipe_users' , ' tenant_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
@@ -472,7 +577,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
472
577
ALTER TABLE tenant_configs
473
578
ADD PRIMARY KEY (connection_uri_domain, app_id, tenant_id);
474
579
475
- -- ----------------------------------------------------------
580
+ --
476
581
477
582
CREATE TABLE IF NOT EXISTS tenant_thirdparty_providers (
478
583
connection_uri_domain VARCHAR (256 ) DEFAULT ' ' ,
@@ -505,7 +610,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
505
610
ADD FOREIGN KEY (connection_uri_domain, app_id, tenant_id)
506
611
REFERENCES tenant_configs (connection_uri_domain, app_id, tenant_id) ON DELETE CASCADE ;
507
612
508
- -- ----------------------------------------------------------
613
+ --
509
614
510
615
CREATE TABLE IF NOT EXISTS tenant_thirdparty_provider_clients (
511
616
connection_uri_domain VARCHAR (256 ) DEFAULT ' ' ,
@@ -542,7 +647,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
542
647
543
648
CREATE INDEX session_expiry_index ON session_info (expires_at);
544
649
545
- -- ----------------------------------------------------------
650
+ --
546
651
547
652
CALL st_add_column_if_not_exists(' session_access_token_signing_keys' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
548
653
@@ -575,7 +680,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
575
680
ADD FOREIGN KEY (app_id)
576
681
REFERENCES apps (app_id) ON DELETE CASCADE ;
577
682
578
- -- ----------------------------------------------------------
683
+ --
579
684
580
685
CALL st_add_column_if_not_exists(' emailverification_tokens' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
581
686
CALL st_add_column_if_not_exists(' emailverification_tokens' , ' tenant_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
@@ -603,7 +708,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
603
708
ADD FOREIGN KEY (app_id, user_id)
604
709
REFERENCES app_id_to_user_id (app_id, user_id) ON DELETE CASCADE ;
605
710
606
- -- ------------------------------------------------------------
711
+ -- --
607
712
608
713
CREATE TABLE IF NOT EXISTS emailpassword_user_to_tenant (
609
714
app_id VARCHAR (64 ) DEFAULT ' public' ,
@@ -625,7 +730,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
625
730
INSERT IGNORE INTO emailpassword_user_to_tenant (user_id, email)
626
731
SELECT user_id, email FROM emailpassword_users;
627
732
628
- -- ----------------------------------------------------------
733
+ --
629
734
630
735
CALL st_add_column_if_not_exists(' emailpassword_pswd_reset_tokens' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
631
736
@@ -652,7 +757,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
652
757
ADD FOREIGN KEY (app_id, user_id)
653
758
REFERENCES app_id_to_user_id (app_id, user_id) ON DELETE CASCADE ;
654
759
655
- -- ----------------------------------------------------------
760
+ --
656
761
657
762
CREATE TABLE IF NOT EXISTS passwordless_user_to_tenant (
658
763
app_id VARCHAR (64 ) DEFAULT ' public' ,
@@ -678,7 +783,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
678
783
INSERT IGNORE INTO passwordless_user_to_tenant (user_id, email, phone_number)
679
784
SELECT user_id, email, phone_number FROM passwordless_users;
680
785
681
- -- ----------------------------------------------------------
786
+ --
682
787
683
788
CALL st_add_column_if_not_exists(' passwordless_devices' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
684
789
CALL st_add_column_if_not_exists(' passwordless_devices' , ' tenant_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
@@ -694,7 +799,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
694
799
695
800
CREATE INDEX passwordless_devices_phone_number_index ON passwordless_devices (app_id, tenant_id, phone_number);
696
801
697
- -- ----------------------------------------------------------
802
+ --
698
803
699
804
CALL st_add_column_if_not_exists(' passwordless_codes' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
700
805
CALL st_add_column_if_not_exists(' passwordless_codes' , ' tenant_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
@@ -727,7 +832,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
727
832
728
833
CREATE INDEX thirdparty_users_email_index ON thirdparty_users (app_id, email);
729
834
730
- -- ----------------------------------------------------------
835
+ --
731
836
732
837
CREATE TABLE IF NOT EXISTS thirdparty_user_to_tenant (
733
838
app_id VARCHAR (64 ) DEFAULT ' public' ,
@@ -781,7 +886,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
781
886
ADD FOREIGN KEY (app_id)
782
887
REFERENCES apps (app_id) ON DELETE CASCADE ;
783
888
784
- -- ----------------------------------------------------------
889
+ --
785
890
786
891
CALL st_add_column_if_not_exists(' role_permissions' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
787
892
@@ -794,7 +899,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
794
899
795
900
CREATE INDEX role_permissions_permission_index ON role_permissions (app_id, permission);
796
901
797
- -- ----------------------------------------------------------
902
+ --
798
903
799
904
CALL st_add_column_if_not_exists(' user_roles' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
800
905
CALL st_add_column_if_not_exists(' user_roles' , ' tenant_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
@@ -838,7 +943,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
838
943
ADD FOREIGN KEY (app_id)
839
944
REFERENCES apps (app_id) ON DELETE CASCADE ;
840
945
841
- -- ----------------------------------------------------------
946
+ --
842
947
843
948
CALL st_add_column_if_not_exists(' dashboard_user_sessions' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
844
949
@@ -862,7 +967,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
862
967
ADD FOREIGN KEY (app_id)
863
968
REFERENCES apps (app_id) ON DELETE CASCADE ;
864
969
865
- -- ----------------------------------------------------------
970
+ --
866
971
867
972
CALL st_add_column_if_not_exists(' totp_user_devices' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
868
973
@@ -873,7 +978,7 @@ CREATE INDEX app_id_to_user_id_user_id_index ON app_id_to_user_id (user_id);
873
978
ADD FOREIGN KEY (app_id, user_id)
874
979
REFERENCES totp_users (app_id, user_id) ON DELETE CASCADE ;
875
980
876
- -- ----------------------------------------------------------
981
+ --
877
982
878
983
CALL st_add_column_if_not_exists(' totp_used_codes' , ' app_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
879
984
CALL st_add_column_if_not_exists(' totp_used_codes' , ' tenant_id' , ' VARCHAR(64)' , ' NOT NULL DEFAULT \' public\' ' , @status_message);
0 commit comments