@authhero/drizzle 0.13.1 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -159,12 +159,18 @@ CREATE TABLE `login_sessions` (
159
159
  `ip` text(39),
160
160
  `useragent` text,
161
161
  `auth0Client` text(255),
162
- `login_completed` integer DEFAULT 0,
162
+ `state` text(50) DEFAULT 'pending' NOT NULL,
163
+ `state_data` text,
164
+ `failure_reason` text,
165
+ `user_id` text(255),
163
166
  PRIMARY KEY(`tenant_id`, `id`),
164
167
  FOREIGN KEY (`tenant_id`) REFERENCES `tenants`(`id`) ON UPDATE no action ON DELETE cascade
165
168
  );
166
169
  --> statement-breakpoint
167
170
  CREATE INDEX `login_sessions_id_index` ON `login_sessions` (`id`);--> statement-breakpoint
171
+ CREATE INDEX `login_sessions_state_idx` ON `login_sessions` (`state`);--> statement-breakpoint
172
+ CREATE INDEX `login_sessions_state_updated_idx` ON `login_sessions` (`state`,`updated_at`);--> statement-breakpoint
173
+ CREATE INDEX `login_sessions_tenant_user_idx` ON `login_sessions` (`tenant_id`,`user_id`);--> statement-breakpoint
168
174
  CREATE TABLE `otps` (
169
175
  `tenant_id` text(191) NOT NULL,
170
176
  `id` text(255) PRIMARY KEY NOT NULL,
@@ -317,13 +323,13 @@ CREATE TABLE `clients` (
317
323
  );
318
324
  --> statement-breakpoint
319
325
  CREATE TABLE `connections` (
320
- `id` text(255) PRIMARY KEY NOT NULL,
326
+ `id` text(255) NOT NULL,
321
327
  `tenant_id` text(191) NOT NULL,
322
328
  `name` text(255) NOT NULL,
323
329
  `response_type` text(255),
324
330
  `response_mode` text(255),
325
331
  `strategy` text(64),
326
- `options` text(2048) DEFAULT '{}' NOT NULL,
332
+ `options` text(8192) DEFAULT '{}' NOT NULL,
327
333
  `created_at` text(35) NOT NULL,
328
334
  `updated_at` text(35) NOT NULL,
329
335
  `display_name` text(255),
@@ -331,10 +337,12 @@ CREATE TABLE `connections` (
331
337
  `show_as_button` integer,
332
338
  `is_system` integer DEFAULT 0 NOT NULL,
333
339
  `metadata` text(4096),
340
+ PRIMARY KEY(`tenant_id`, `id`),
334
341
  FOREIGN KEY (`tenant_id`) REFERENCES `tenants`(`id`) ON UPDATE no action ON DELETE cascade
335
342
  );
336
343
  --> statement-breakpoint
337
344
  CREATE INDEX `connections_tenant_id_index` ON `connections` (`tenant_id`);--> statement-breakpoint
345
+ CREATE UNIQUE INDEX `connections_id_unique` ON `connections` (`id`);--> statement-breakpoint
338
346
  CREATE TABLE `custom_domains` (
339
347
  `custom_domain_id` text(256) PRIMARY KEY NOT NULL,
340
348
  `tenant_id` text(191) NOT NULL,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "6",
3
3
  "dialect": "sqlite",
4
- "id": "2e08570c-9165-450c-898f-ebfcbc10cf32",
4
+ "id": "18d1a52e-e035-4e11-8380-4010025f05a2",
5
5
  "prevId": "00000000-0000-0000-0000-000000000000",
6
6
  "tables": {
7
7
  "tenants": {
@@ -1114,13 +1114,34 @@
1114
1114
  "notNull": false,
1115
1115
  "autoincrement": false
1116
1116
  },
1117
- "login_completed": {
1118
- "name": "login_completed",
1119
- "type": "integer",
1117
+ "state": {
1118
+ "name": "state",
1119
+ "type": "text(50)",
1120
1120
  "primaryKey": false,
1121
- "notNull": false,
1121
+ "notNull": true,
1122
1122
  "autoincrement": false,
1123
- "default": 0
1123
+ "default": "'pending'"
1124
+ },
1125
+ "state_data": {
1126
+ "name": "state_data",
1127
+ "type": "text",
1128
+ "primaryKey": false,
1129
+ "notNull": false,
1130
+ "autoincrement": false
1131
+ },
1132
+ "failure_reason": {
1133
+ "name": "failure_reason",
1134
+ "type": "text",
1135
+ "primaryKey": false,
1136
+ "notNull": false,
1137
+ "autoincrement": false
1138
+ },
1139
+ "user_id": {
1140
+ "name": "user_id",
1141
+ "type": "text(255)",
1142
+ "primaryKey": false,
1143
+ "notNull": false,
1144
+ "autoincrement": false
1124
1145
  }
1125
1146
  },
1126
1147
  "indexes": {
@@ -1130,6 +1151,29 @@
1130
1151
  "id"
1131
1152
  ],
1132
1153
  "isUnique": false
1154
+ },
1155
+ "login_sessions_state_idx": {
1156
+ "name": "login_sessions_state_idx",
1157
+ "columns": [
1158
+ "state"
1159
+ ],
1160
+ "isUnique": false
1161
+ },
1162
+ "login_sessions_state_updated_idx": {
1163
+ "name": "login_sessions_state_updated_idx",
1164
+ "columns": [
1165
+ "state",
1166
+ "updated_at"
1167
+ ],
1168
+ "isUnique": false
1169
+ },
1170
+ "login_sessions_tenant_user_idx": {
1171
+ "name": "login_sessions_tenant_user_idx",
1172
+ "columns": [
1173
+ "tenant_id",
1174
+ "user_id"
1175
+ ],
1176
+ "isUnique": false
1133
1177
  }
1134
1178
  },
1135
1179
  "foreignKeys": {
@@ -2223,7 +2267,7 @@
2223
2267
  "id": {
2224
2268
  "name": "id",
2225
2269
  "type": "text(255)",
2226
- "primaryKey": true,
2270
+ "primaryKey": false,
2227
2271
  "notNull": true,
2228
2272
  "autoincrement": false
2229
2273
  },
@@ -2264,7 +2308,7 @@
2264
2308
  },
2265
2309
  "options": {
2266
2310
  "name": "options",
2267
- "type": "text(2048)",
2311
+ "type": "text(8192)",
2268
2312
  "primaryKey": false,
2269
2313
  "notNull": true,
2270
2314
  "autoincrement": false,
@@ -2328,6 +2372,13 @@
2328
2372
  "tenant_id"
2329
2373
  ],
2330
2374
  "isUnique": false
2375
+ },
2376
+ "connections_id_unique": {
2377
+ "name": "connections_id_unique",
2378
+ "columns": [
2379
+ "id"
2380
+ ],
2381
+ "isUnique": true
2331
2382
  }
2332
2383
  },
2333
2384
  "foreignKeys": {
@@ -2345,7 +2396,15 @@
2345
2396
  "onUpdate": "no action"
2346
2397
  }
2347
2398
  },
2348
- "compositePrimaryKeys": {},
2399
+ "compositePrimaryKeys": {
2400
+ "connections_tenant_id_id_pk": {
2401
+ "columns": [
2402
+ "tenant_id",
2403
+ "id"
2404
+ ],
2405
+ "name": "connections_tenant_id_id_pk"
2406
+ }
2407
+ },
2349
2408
  "uniqueConstraints": {},
2350
2409
  "checkConstraints": {}
2351
2410
  },
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "version": "6",
3
3
  "dialect": "sqlite",
4
- "id": "531f1055-83e0-4c4c-8076-e158c192d76f",
5
- "prevId": "2e08570c-9165-450c-898f-ebfcbc10cf32",
4
+ "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
5
+ "prevId": "531f1055-83e0-4c4c-8076-e158c192d76f",
6
6
  "tables": {
7
7
  "tenants": {
8
8
  "name": "tenants",
@@ -383,12 +383,8 @@
383
383
  "name": "passwords_tenant_id_tenants_id_fk",
384
384
  "tableFrom": "passwords",
385
385
  "tableTo": "tenants",
386
- "columnsFrom": [
387
- "tenant_id"
388
- ],
389
- "columnsTo": [
390
- "id"
391
- ],
386
+ "columnsFrom": ["tenant_id"],
387
+ "columnsTo": ["id"],
392
388
  "onDelete": "cascade",
393
389
  "onUpdate": "no action"
394
390
  }
@@ -588,50 +584,32 @@
588
584
  "indexes": {
589
585
  "unique_email_provider": {
590
586
  "name": "unique_email_provider",
591
- "columns": [
592
- "email",
593
- "provider",
594
- "tenant_id"
595
- ],
587
+ "columns": ["email", "provider", "tenant_id"],
596
588
  "isUnique": true
597
589
  },
598
590
  "unique_phone_provider": {
599
591
  "name": "unique_phone_provider",
600
- "columns": [
601
- "phone_number",
602
- "provider",
603
- "tenant_id"
604
- ],
592
+ "columns": ["phone_number", "provider", "tenant_id"],
605
593
  "isUnique": true
606
594
  },
607
595
  "users_email_index": {
608
596
  "name": "users_email_index",
609
- "columns": [
610
- "email"
611
- ],
597
+ "columns": ["email"],
612
598
  "isUnique": false
613
599
  },
614
600
  "users_linked_to_index": {
615
601
  "name": "users_linked_to_index",
616
- "columns": [
617
- "linked_to"
618
- ],
602
+ "columns": ["linked_to"],
619
603
  "isUnique": false
620
604
  },
621
605
  "users_name_index": {
622
606
  "name": "users_name_index",
623
- "columns": [
624
- "name"
625
- ],
607
+ "columns": ["name"],
626
608
  "isUnique": false
627
609
  },
628
610
  "users_phone_tenant_provider_index": {
629
611
  "name": "users_phone_tenant_provider_index",
630
- "columns": [
631
- "tenant_id",
632
- "phone_number",
633
- "provider"
634
- ],
612
+ "columns": ["tenant_id", "phone_number", "provider"],
635
613
  "isUnique": false
636
614
  }
637
615
  },
@@ -640,22 +618,15 @@
640
618
  "name": "users_tenant_id_tenants_id_fk",
641
619
  "tableFrom": "users",
642
620
  "tableTo": "tenants",
643
- "columnsFrom": [
644
- "tenant_id"
645
- ],
646
- "columnsTo": [
647
- "id"
648
- ],
621
+ "columnsFrom": ["tenant_id"],
622
+ "columnsTo": ["id"],
649
623
  "onDelete": "cascade",
650
624
  "onUpdate": "no action"
651
625
  }
652
626
  },
653
627
  "compositePrimaryKeys": {
654
628
  "users_tenants": {
655
- "columns": [
656
- "user_id",
657
- "tenant_id"
658
- ],
629
+ "columns": ["user_id", "tenant_id"],
659
630
  "name": "users_tenants"
660
631
  }
661
632
  },
@@ -763,12 +734,8 @@
763
734
  "name": "authentication_codes_tenant_id_tenants_id_fk",
764
735
  "tableFrom": "authentication_codes",
765
736
  "tableTo": "tenants",
766
- "columnsFrom": [
767
- "tenant_id"
768
- ],
769
- "columnsTo": [
770
- "id"
771
- ],
737
+ "columnsFrom": ["tenant_id"],
738
+ "columnsTo": ["id"],
772
739
  "onDelete": "cascade",
773
740
  "onUpdate": "no action"
774
741
  }
@@ -889,9 +856,7 @@
889
856
  "indexes": {
890
857
  "codes_expires_at_index": {
891
858
  "name": "codes_expires_at_index",
892
- "columns": [
893
- "expires_at"
894
- ],
859
+ "columns": ["expires_at"],
895
860
  "isUnique": false
896
861
  }
897
862
  },
@@ -900,22 +865,15 @@
900
865
  "name": "codes_tenant_id_tenants_id_fk",
901
866
  "tableFrom": "codes",
902
867
  "tableTo": "tenants",
903
- "columnsFrom": [
904
- "tenant_id"
905
- ],
906
- "columnsTo": [
907
- "id"
908
- ],
868
+ "columnsFrom": ["tenant_id"],
869
+ "columnsTo": ["id"],
909
870
  "onDelete": "cascade",
910
871
  "onUpdate": "no action"
911
872
  }
912
873
  },
913
874
  "compositePrimaryKeys": {
914
875
  "PK_codes_code_id_code_type": {
915
- "columns": [
916
- "code_id",
917
- "code_type"
918
- ],
876
+ "columns": ["code_id", "code_type"],
919
877
  "name": "PK_codes_code_id_code_type"
920
878
  }
921
879
  },
@@ -1126,9 +1084,7 @@
1126
1084
  "indexes": {
1127
1085
  "login_sessions_id_index": {
1128
1086
  "name": "login_sessions_id_index",
1129
- "columns": [
1130
- "id"
1131
- ],
1087
+ "columns": ["id"],
1132
1088
  "isUnique": false
1133
1089
  }
1134
1090
  },
@@ -1137,22 +1093,15 @@
1137
1093
  "name": "login_sessions_tenant_id_tenants_id_fk",
1138
1094
  "tableFrom": "login_sessions",
1139
1095
  "tableTo": "tenants",
1140
- "columnsFrom": [
1141
- "tenant_id"
1142
- ],
1143
- "columnsTo": [
1144
- "id"
1145
- ],
1096
+ "columnsFrom": ["tenant_id"],
1097
+ "columnsTo": ["id"],
1146
1098
  "onDelete": "cascade",
1147
1099
  "onUpdate": "no action"
1148
1100
  }
1149
1101
  },
1150
1102
  "compositePrimaryKeys": {
1151
1103
  "login_sessions_pk": {
1152
- "columns": [
1153
- "tenant_id",
1154
- "id"
1155
- ],
1104
+ "columns": ["tenant_id", "id"],
1156
1105
  "name": "login_sessions_pk"
1157
1106
  }
1158
1107
  },
@@ -1292,16 +1241,12 @@
1292
1241
  "indexes": {
1293
1242
  "otps_email_index": {
1294
1243
  "name": "otps_email_index",
1295
- "columns": [
1296
- "email"
1297
- ],
1244
+ "columns": ["email"],
1298
1245
  "isUnique": false
1299
1246
  },
1300
1247
  "otps_expires_at_index": {
1301
1248
  "name": "otps_expires_at_index",
1302
- "columns": [
1303
- "expires_at"
1304
- ],
1249
+ "columns": ["expires_at"],
1305
1250
  "isUnique": false
1306
1251
  }
1307
1252
  },
@@ -1310,12 +1255,8 @@
1310
1255
  "name": "otps_tenant_id_tenants_id_fk",
1311
1256
  "tableFrom": "otps",
1312
1257
  "tableTo": "tenants",
1313
- "columnsFrom": [
1314
- "tenant_id"
1315
- ],
1316
- "columnsTo": [
1317
- "id"
1318
- ],
1258
+ "columnsFrom": ["tenant_id"],
1259
+ "columnsTo": ["id"],
1319
1260
  "onDelete": "cascade",
1320
1261
  "onUpdate": "no action"
1321
1262
  }
@@ -1418,22 +1359,15 @@
1418
1359
  "name": "refresh_tokens_tenant_id_tenants_id_fk",
1419
1360
  "tableFrom": "refresh_tokens",
1420
1361
  "tableTo": "tenants",
1421
- "columnsFrom": [
1422
- "tenant_id"
1423
- ],
1424
- "columnsTo": [
1425
- "id"
1426
- ],
1362
+ "columnsFrom": ["tenant_id"],
1363
+ "columnsTo": ["id"],
1427
1364
  "onDelete": "cascade",
1428
1365
  "onUpdate": "no action"
1429
1366
  }
1430
1367
  },
1431
1368
  "compositePrimaryKeys": {
1432
1369
  "refresh_tokens_pk": {
1433
- "columns": [
1434
- "tenant_id",
1435
- "id"
1436
- ],
1370
+ "columns": ["tenant_id", "id"],
1437
1371
  "name": "refresh_tokens_pk"
1438
1372
  }
1439
1373
  },
@@ -1545,9 +1479,7 @@
1545
1479
  "indexes": {
1546
1480
  "IDX_sessions_login_session_id": {
1547
1481
  "name": "IDX_sessions_login_session_id",
1548
- "columns": [
1549
- "login_session_id"
1550
- ],
1482
+ "columns": ["login_session_id"],
1551
1483
  "isUnique": false
1552
1484
  }
1553
1485
  },
@@ -1556,22 +1488,15 @@
1556
1488
  "name": "sessions_tenant_id_tenants_id_fk",
1557
1489
  "tableFrom": "sessions",
1558
1490
  "tableTo": "tenants",
1559
- "columnsFrom": [
1560
- "tenant_id"
1561
- ],
1562
- "columnsTo": [
1563
- "id"
1564
- ],
1491
+ "columnsFrom": ["tenant_id"],
1492
+ "columnsTo": ["id"],
1565
1493
  "onDelete": "cascade",
1566
1494
  "onUpdate": "no action"
1567
1495
  }
1568
1496
  },
1569
1497
  "compositePrimaryKeys": {
1570
1498
  "sessions_pk": {
1571
- "columns": [
1572
- "tenant_id",
1573
- "id"
1574
- ],
1499
+ "columns": ["tenant_id", "id"],
1575
1500
  "name": "sessions_pk"
1576
1501
  }
1577
1502
  },
@@ -1679,12 +1604,8 @@
1679
1604
  "name": "tickets_tenant_id_tenants_id_fk",
1680
1605
  "tableFrom": "tickets",
1681
1606
  "tableTo": "tenants",
1682
- "columnsFrom": [
1683
- "tenant_id"
1684
- ],
1685
- "columnsTo": [
1686
- "id"
1687
- ],
1607
+ "columnsFrom": ["tenant_id"],
1608
+ "columnsTo": ["id"],
1688
1609
  "onDelete": "cascade",
1689
1610
  "onUpdate": "no action"
1690
1611
  }
@@ -1788,9 +1709,7 @@
1788
1709
  "indexes": {
1789
1710
  "idx_client_grants_audience": {
1790
1711
  "name": "idx_client_grants_audience",
1791
- "columns": [
1792
- "audience"
1793
- ],
1712
+ "columns": ["audience"],
1794
1713
  "isUnique": false
1795
1714
  }
1796
1715
  },
@@ -1799,22 +1718,15 @@
1799
1718
  "name": "client_grants_tenant_id_tenants_id_fk",
1800
1719
  "tableFrom": "client_grants",
1801
1720
  "tableTo": "tenants",
1802
- "columnsFrom": [
1803
- "tenant_id"
1804
- ],
1805
- "columnsTo": [
1806
- "id"
1807
- ],
1721
+ "columnsFrom": ["tenant_id"],
1722
+ "columnsTo": ["id"],
1808
1723
  "onDelete": "cascade",
1809
1724
  "onUpdate": "no action"
1810
1725
  }
1811
1726
  },
1812
1727
  "compositePrimaryKeys": {
1813
1728
  "pk_client_grants": {
1814
- "columns": [
1815
- "tenant_id",
1816
- "id"
1817
- ],
1729
+ "columns": ["tenant_id", "id"],
1818
1730
  "name": "pk_client_grants"
1819
1731
  }
1820
1732
  },
@@ -2195,22 +2107,15 @@
2195
2107
  "name": "clients_tenant_id_tenants_id_fk",
2196
2108
  "tableFrom": "clients",
2197
2109
  "tableTo": "tenants",
2198
- "columnsFrom": [
2199
- "tenant_id"
2200
- ],
2201
- "columnsTo": [
2202
- "id"
2203
- ],
2110
+ "columnsFrom": ["tenant_id"],
2111
+ "columnsTo": ["id"],
2204
2112
  "onDelete": "cascade",
2205
2113
  "onUpdate": "no action"
2206
2114
  }
2207
2115
  },
2208
2116
  "compositePrimaryKeys": {
2209
2117
  "clients_tenant_id_client_id": {
2210
- "columns": [
2211
- "tenant_id",
2212
- "client_id"
2213
- ],
2118
+ "columns": ["tenant_id", "client_id"],
2214
2119
  "name": "clients_tenant_id_client_id"
2215
2120
  }
2216
2121
  },
@@ -2324,10 +2229,13 @@
2324
2229
  "indexes": {
2325
2230
  "connections_tenant_id_index": {
2326
2231
  "name": "connections_tenant_id_index",
2327
- "columns": [
2328
- "tenant_id"
2329
- ],
2232
+ "columns": ["tenant_id"],
2330
2233
  "isUnique": false
2234
+ },
2235
+ "connections_id_unique": {
2236
+ "name": "connections_id_unique",
2237
+ "columns": ["id"],
2238
+ "isUnique": true
2331
2239
  }
2332
2240
  },
2333
2241
  "foreignKeys": {
@@ -2335,22 +2243,15 @@
2335
2243
  "name": "connections_tenant_id_tenants_id_fk",
2336
2244
  "tableFrom": "connections",
2337
2245
  "tableTo": "tenants",
2338
- "columnsFrom": [
2339
- "tenant_id"
2340
- ],
2341
- "columnsTo": [
2342
- "id"
2343
- ],
2246
+ "columnsFrom": ["tenant_id"],
2247
+ "columnsTo": ["id"],
2344
2248
  "onDelete": "cascade",
2345
2249
  "onUpdate": "no action"
2346
2250
  }
2347
2251
  },
2348
2252
  "compositePrimaryKeys": {
2349
2253
  "connections_tenant_id_id_pk": {
2350
- "columns": [
2351
- "tenant_id",
2352
- "id"
2353
- ],
2254
+ "columns": ["tenant_id", "id"],
2354
2255
  "name": "connections_tenant_id_id_pk"
2355
2256
  }
2356
2257
  },
@@ -2458,12 +2359,8 @@
2458
2359
  "name": "custom_domains_tenant_id_tenants_id_fk",
2459
2360
  "tableFrom": "custom_domains",
2460
2361
  "tableTo": "tenants",
2461
- "columnsFrom": [
2462
- "tenant_id"
2463
- ],
2464
- "columnsTo": [
2465
- "id"
2466
- ],
2362
+ "columnsFrom": ["tenant_id"],
2363
+ "columnsTo": ["id"],
2467
2364
  "onDelete": "cascade",
2468
2365
  "onUpdate": "no action"
2469
2366
  }
@@ -2545,12 +2442,8 @@
2545
2442
  "name": "domains_tenant_id_tenants_id_fk",
2546
2443
  "tableFrom": "domains",
2547
2444
  "tableTo": "tenants",
2548
- "columnsFrom": [
2549
- "tenant_id"
2550
- ],
2551
- "columnsTo": [
2552
- "id"
2553
- ],
2445
+ "columnsFrom": ["tenant_id"],
2446
+ "columnsTo": ["id"],
2554
2447
  "onDelete": "cascade",
2555
2448
  "onUpdate": "no action"
2556
2449
  }
@@ -2678,31 +2571,22 @@
2678
2571
  "indexes": {
2679
2572
  "idx_invites_tenant_id": {
2680
2573
  "name": "idx_invites_tenant_id",
2681
- "columns": [
2682
- "tenant_id"
2683
- ],
2574
+ "columns": ["tenant_id"],
2684
2575
  "isUnique": false
2685
2576
  },
2686
2577
  "idx_invites_organization_id": {
2687
2578
  "name": "idx_invites_organization_id",
2688
- "columns": [
2689
- "organization_id"
2690
- ],
2579
+ "columns": ["organization_id"],
2691
2580
  "isUnique": false
2692
2581
  },
2693
2582
  "idx_invites_expires_at": {
2694
2583
  "name": "idx_invites_expires_at",
2695
- "columns": [
2696
- "expires_at"
2697
- ],
2584
+ "columns": ["expires_at"],
2698
2585
  "isUnique": false
2699
2586
  },
2700
2587
  "idx_invites_tenant_created": {
2701
2588
  "name": "idx_invites_tenant_created",
2702
- "columns": [
2703
- "tenant_id",
2704
- "created_at"
2705
- ],
2589
+ "columns": ["tenant_id", "created_at"],
2706
2590
  "isUnique": false
2707
2591
  }
2708
2592
  },
@@ -2788,9 +2672,7 @@
2788
2672
  "indexes": {
2789
2673
  "idx_organizations_tenant_id": {
2790
2674
  "name": "idx_organizations_tenant_id",
2791
- "columns": [
2792
- "tenant_id"
2793
- ],
2675
+ "columns": ["tenant_id"],
2794
2676
  "isUnique": false
2795
2677
  }
2796
2678
  },
@@ -2848,32 +2730,22 @@
2848
2730
  "indexes": {
2849
2731
  "user_organizations_unique": {
2850
2732
  "name": "user_organizations_unique",
2851
- "columns": [
2852
- "tenant_id",
2853
- "user_id",
2854
- "organization_id"
2855
- ],
2733
+ "columns": ["tenant_id", "user_id", "organization_id"],
2856
2734
  "isUnique": true
2857
2735
  },
2858
2736
  "idx_user_organizations_tenant_id": {
2859
2737
  "name": "idx_user_organizations_tenant_id",
2860
- "columns": [
2861
- "tenant_id"
2862
- ],
2738
+ "columns": ["tenant_id"],
2863
2739
  "isUnique": false
2864
2740
  },
2865
2741
  "idx_user_organizations_user_id": {
2866
2742
  "name": "idx_user_organizations_user_id",
2867
- "columns": [
2868
- "user_id"
2869
- ],
2743
+ "columns": ["user_id"],
2870
2744
  "isUnique": false
2871
2745
  },
2872
2746
  "idx_user_organizations_organization_id": {
2873
2747
  "name": "idx_user_organizations_organization_id",
2874
- "columns": [
2875
- "organization_id"
2876
- ],
2748
+ "columns": ["organization_id"],
2877
2749
  "isUnique": false
2878
2750
  }
2879
2751
  },
@@ -3003,10 +2875,7 @@
3003
2875
  "foreignKeys": {},
3004
2876
  "compositePrimaryKeys": {
3005
2877
  "resource_servers_pk": {
3006
- "columns": [
3007
- "tenant_id",
3008
- "id"
3009
- ],
2878
+ "columns": ["tenant_id", "id"],
3010
2879
  "name": "resource_servers_pk"
3011
2880
  }
3012
2881
  },
@@ -3055,10 +2924,7 @@
3055
2924
  "indexes": {
3056
2925
  "role_permissions_role_fk": {
3057
2926
  "name": "role_permissions_role_fk",
3058
- "columns": [
3059
- "tenant_id",
3060
- "role_id"
3061
- ],
2927
+ "columns": ["tenant_id", "role_id"],
3062
2928
  "isUnique": false
3063
2929
  },
3064
2930
  "role_permissions_permission_fk": {
@@ -3144,10 +3010,7 @@
3144
3010
  "foreignKeys": {},
3145
3011
  "compositePrimaryKeys": {
3146
3012
  "roles_pk": {
3147
- "columns": [
3148
- "tenant_id",
3149
- "id"
3150
- ],
3013
+ "columns": ["tenant_id", "id"],
3151
3014
  "name": "roles_pk"
3152
3015
  }
3153
3016
  },
@@ -3204,10 +3067,7 @@
3204
3067
  "indexes": {
3205
3068
  "user_permissions_user_fk": {
3206
3069
  "name": "user_permissions_user_fk",
3207
- "columns": [
3208
- "tenant_id",
3209
- "user_id"
3210
- ],
3070
+ "columns": ["tenant_id", "user_id"],
3211
3071
  "isUnique": false
3212
3072
  },
3213
3073
  "user_permissions_permission_fk": {
@@ -3221,9 +3081,7 @@
3221
3081
  },
3222
3082
  "user_permissions_organization_fk": {
3223
3083
  "name": "user_permissions_organization_fk",
3224
- "columns": [
3225
- "organization_id"
3226
- ],
3084
+ "columns": ["organization_id"],
3227
3085
  "isUnique": false
3228
3086
  }
3229
3087
  },
@@ -3286,37 +3144,24 @@
3286
3144
  "indexes": {
3287
3145
  "user_roles_user_fk": {
3288
3146
  "name": "user_roles_user_fk",
3289
- "columns": [
3290
- "tenant_id",
3291
- "user_id"
3292
- ],
3147
+ "columns": ["tenant_id", "user_id"],
3293
3148
  "isUnique": false
3294
3149
  },
3295
3150
  "user_roles_role_fk": {
3296
3151
  "name": "user_roles_role_fk",
3297
- "columns": [
3298
- "tenant_id",
3299
- "role_id"
3300
- ],
3152
+ "columns": ["tenant_id", "role_id"],
3301
3153
  "isUnique": false
3302
3154
  },
3303
3155
  "user_roles_organization_fk": {
3304
3156
  "name": "user_roles_organization_fk",
3305
- "columns": [
3306
- "organization_id"
3307
- ],
3157
+ "columns": ["organization_id"],
3308
3158
  "isUnique": false
3309
3159
  }
3310
3160
  },
3311
3161
  "foreignKeys": {},
3312
3162
  "compositePrimaryKeys": {
3313
3163
  "user_roles_pk": {
3314
- "columns": [
3315
- "tenant_id",
3316
- "user_id",
3317
- "role_id",
3318
- "organization_id"
3319
- ],
3164
+ "columns": ["tenant_id", "user_id", "role_id", "organization_id"],
3320
3165
  "name": "user_roles_pk"
3321
3166
  }
3322
3167
  },
@@ -3396,12 +3241,8 @@
3396
3241
  "name": "branding_tenant_id_tenants_id_fk",
3397
3242
  "tableFrom": "branding",
3398
3243
  "tableTo": "tenants",
3399
- "columnsFrom": [
3400
- "tenant_id"
3401
- ],
3402
- "columnsTo": [
3403
- "id"
3404
- ],
3244
+ "columnsFrom": ["tenant_id"],
3245
+ "columnsTo": ["id"],
3405
3246
  "onDelete": "cascade",
3406
3247
  "onUpdate": "no action"
3407
3248
  }
@@ -3527,9 +3368,7 @@
3527
3368
  "indexes": {
3528
3369
  "flows_tenant_id_idx": {
3529
3370
  "name": "flows_tenant_id_idx",
3530
- "columns": [
3531
- "tenant_id"
3532
- ],
3371
+ "columns": ["tenant_id"],
3533
3372
  "isUnique": false
3534
3373
  }
3535
3374
  },
@@ -3538,12 +3377,8 @@
3538
3377
  "name": "flows_tenant_id_tenants_id_fk",
3539
3378
  "tableFrom": "flows",
3540
3379
  "tableTo": "tenants",
3541
- "columnsFrom": [
3542
- "tenant_id"
3543
- ],
3544
- "columnsTo": [
3545
- "id"
3546
- ],
3380
+ "columnsFrom": ["tenant_id"],
3381
+ "columnsTo": ["id"],
3547
3382
  "onDelete": "cascade",
3548
3383
  "onUpdate": "no action"
3549
3384
  }
@@ -3643,9 +3478,7 @@
3643
3478
  "indexes": {
3644
3479
  "forms_tenant_id_idx": {
3645
3480
  "name": "forms_tenant_id_idx",
3646
- "columns": [
3647
- "tenant_id"
3648
- ],
3481
+ "columns": ["tenant_id"],
3649
3482
  "isUnique": false
3650
3483
  }
3651
3484
  },
@@ -3654,12 +3487,8 @@
3654
3487
  "name": "forms_tenant_id_tenants_id_fk",
3655
3488
  "tableFrom": "forms",
3656
3489
  "tableTo": "tenants",
3657
- "columnsFrom": [
3658
- "tenant_id"
3659
- ],
3660
- "columnsTo": [
3661
- "id"
3662
- ],
3490
+ "columnsFrom": ["tenant_id"],
3491
+ "columnsTo": ["id"],
3663
3492
  "onDelete": "cascade",
3664
3493
  "onUpdate": "no action"
3665
3494
  }
@@ -3756,12 +3585,8 @@
3756
3585
  "name": "hooks_tenant_id_tenants_id_fk",
3757
3586
  "tableFrom": "hooks",
3758
3587
  "tableTo": "tenants",
3759
- "columnsFrom": [
3760
- "tenant_id"
3761
- ],
3762
- "columnsTo": [
3763
- "id"
3764
- ],
3588
+ "columnsFrom": ["tenant_id"],
3589
+ "columnsTo": ["id"],
3765
3590
  "onDelete": "cascade",
3766
3591
  "onUpdate": "no action"
3767
3592
  }
@@ -3865,12 +3690,8 @@
3865
3690
  "name": "keys_tenant_id_tenants_id_fk",
3866
3691
  "tableFrom": "keys",
3867
3692
  "tableTo": "tenants",
3868
- "columnsFrom": [
3869
- "tenant_id"
3870
- ],
3871
- "columnsTo": [
3872
- "id"
3873
- ],
3693
+ "columnsFrom": ["tenant_id"],
3694
+ "columnsTo": ["id"],
3874
3695
  "onDelete": "cascade",
3875
3696
  "onUpdate": "no action"
3876
3697
  },
@@ -3878,12 +3699,8 @@
3878
3699
  "name": "keys_connection_connections_id_fk",
3879
3700
  "tableFrom": "keys",
3880
3701
  "tableTo": "connections",
3881
- "columnsFrom": [
3882
- "connection"
3883
- ],
3884
- "columnsTo": [
3885
- "id"
3886
- ],
3702
+ "columnsFrom": ["connection"],
3703
+ "columnsTo": ["id"],
3887
3704
  "onDelete": "cascade",
3888
3705
  "onUpdate": "no action"
3889
3706
  }
@@ -4340,9 +4157,7 @@
4340
4157
  "indexes": {
4341
4158
  "themes_tenant_id_idx": {
4342
4159
  "name": "themes_tenant_id_idx",
4343
- "columns": [
4344
- "tenant_id"
4345
- ],
4160
+ "columns": ["tenant_id"],
4346
4161
  "isUnique": false
4347
4162
  }
4348
4163
  },
@@ -4351,22 +4166,15 @@
4351
4166
  "name": "themes_tenant_id_tenants_id_fk",
4352
4167
  "tableFrom": "themes",
4353
4168
  "tableTo": "tenants",
4354
- "columnsFrom": [
4355
- "tenant_id"
4356
- ],
4357
- "columnsTo": [
4358
- "id"
4359
- ],
4169
+ "columnsFrom": ["tenant_id"],
4170
+ "columnsTo": ["id"],
4360
4171
  "onDelete": "cascade",
4361
4172
  "onUpdate": "no action"
4362
4173
  }
4363
4174
  },
4364
4175
  "compositePrimaryKeys": {
4365
4176
  "themes_pkey": {
4366
- "columns": [
4367
- "tenant_id",
4368
- "themeId"
4369
- ],
4177
+ "columns": ["tenant_id", "themeId"],
4370
4178
  "name": "themes_pkey"
4371
4179
  }
4372
4180
  },
@@ -4583,33 +4391,22 @@
4583
4391
  "indexes": {
4584
4392
  "logs_user_id": {
4585
4393
  "name": "logs_user_id",
4586
- "columns": [
4587
- "user_id"
4588
- ],
4394
+ "columns": ["user_id"],
4589
4395
  "isUnique": false
4590
4396
  },
4591
4397
  "logs_tenant_id": {
4592
4398
  "name": "logs_tenant_id",
4593
- "columns": [
4594
- "tenant_id"
4595
- ],
4399
+ "columns": ["tenant_id"],
4596
4400
  "isUnique": false
4597
4401
  },
4598
4402
  "logs_date": {
4599
4403
  "name": "logs_date",
4600
- "columns": [
4601
- "date"
4602
- ],
4404
+ "columns": ["date"],
4603
4405
  "isUnique": false
4604
4406
  },
4605
4407
  "IDX_logs_tenant_date_type_user": {
4606
4408
  "name": "IDX_logs_tenant_date_type_user",
4607
- "columns": [
4608
- "tenant_id",
4609
- "date",
4610
- "type",
4611
- "user_id"
4612
- ],
4409
+ "columns": ["tenant_id", "date", "type", "user_id"],
4613
4410
  "isUnique": false
4614
4411
  }
4615
4412
  },
@@ -4629,4 +4426,4 @@
4629
4426
  "internal": {
4630
4427
  "indexes": {}
4631
4428
  }
4632
- }
4429
+ }
@@ -5,16 +5,9 @@
5
5
  {
6
6
  "idx": 0,
7
7
  "version": "6",
8
- "when": 1766739080358,
9
- "tag": "0000_wandering_baron_zemo",
10
- "breakpoints": true
11
- },
12
- {
13
- "idx": 1,
14
- "version": "6",
15
- "when": 1767793966930,
16
- "tag": "0001_connections_composite_key",
8
+ "when": 1768311719931,
9
+ "tag": "0000_quiet_power_pack",
17
10
  "breakpoints": true
18
11
  }
19
12
  ]
20
- }
13
+ }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/markusahlstrand/authhero"
13
13
  },
14
- "version": "0.13.1",
14
+ "version": "0.14.1",
15
15
  "files": [
16
16
  "dist",
17
17
  "src/schema",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "drizzle-orm": "^0.44.2",
44
- "@authhero/adapter-interfaces": "0.120.0"
44
+ "@authhero/adapter-interfaces": "0.122.0"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsc && vite build",
@@ -4,6 +4,7 @@ import {
4
4
  integer,
5
5
  index,
6
6
  primaryKey,
7
+ uniqueIndex,
7
8
  } from "drizzle-orm/sqlite-core";
8
9
  import { tenants } from "./tenants";
9
10
 
@@ -30,6 +31,8 @@ export const connections = sqliteTable(
30
31
  (table) => [
31
32
  primaryKey({ columns: [table.tenant_id, table.id] }),
32
33
  index("connections_tenant_id_index").on(table.tenant_id),
34
+ // Required for keys.connection foreign key reference
35
+ uniqueIndex("connections_id_unique").on(table.id),
33
36
  ],
34
37
  );
35
38
 
@@ -14,6 +14,7 @@ export const roles = sqliteTable(
14
14
  name: text("name", { length: 50 }).notNull(),
15
15
  description: text("description", { length: 255 }),
16
16
  is_system: integer("is_system").notNull().default(0),
17
+ metadata: text("metadata", { length: 4096 }),
17
18
  created_at: text("created_at", { length: 35 }).notNull(),
18
19
  updated_at: text("updated_at", { length: 35 }).notNull(),
19
20
  },
@@ -133,6 +134,7 @@ export const resourceServers = sqliteTable(
133
134
  verification_key: text("verification_key", { length: 4096 }),
134
135
  options: text("options", { length: 4096 }),
135
136
  is_system: integer("is_system").notNull().default(0),
137
+ metadata: text("metadata", { length: 4096 }),
136
138
  created_at: text("created_at", { length: 35 }).notNull(),
137
139
  updated_at: text("updated_at", { length: 35 }).notNull(),
138
140
  },
@@ -1,25 +0,0 @@
1
- PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
- CREATE TABLE `__new_connections` (
3
- `id` text(255) NOT NULL,
4
- `tenant_id` text(191) NOT NULL,
5
- `name` text(255) NOT NULL,
6
- `response_type` text(255),
7
- `response_mode` text(255),
8
- `strategy` text(64),
9
- `options` text(8192) DEFAULT '{}' NOT NULL,
10
- `created_at` text(35) NOT NULL,
11
- `updated_at` text(35) NOT NULL,
12
- `display_name` text(255),
13
- `is_domain_connection` integer,
14
- `show_as_button` integer,
15
- `is_system` integer DEFAULT 0 NOT NULL,
16
- `metadata` text(4096),
17
- PRIMARY KEY(`tenant_id`, `id`),
18
- FOREIGN KEY (`tenant_id`) REFERENCES `tenants`(`id`) ON UPDATE no action ON DELETE cascade
19
- );
20
- --> statement-breakpoint
21
- INSERT INTO `__new_connections`("id", "tenant_id", "name", "response_type", "response_mode", "strategy", "options", "created_at", "updated_at", "display_name", "is_domain_connection", "show_as_button", "is_system", "metadata") SELECT "id", "tenant_id", "name", "response_type", "response_mode", "strategy", "options", "created_at", "updated_at", "display_name", "is_domain_connection", "show_as_button", "is_system", "metadata" FROM `connections`;--> statement-breakpoint
22
- DROP TABLE `connections`;--> statement-breakpoint
23
- ALTER TABLE `__new_connections` RENAME TO `connections`;--> statement-breakpoint
24
- PRAGMA foreign_keys=ON;--> statement-breakpoint
25
- CREATE INDEX `connections_tenant_id_index` ON `connections` (`tenant_id`);