Commit afd7e27
committed
fix(db): give the SSO index migration the concurrent-build convention it skipped
packages/db/scripts/migrate.ts documents the required shape for CONCURRENTLY
statements, and the previous migration follows it. 0284 did not, and the
omission is silently destructive.
migrate.ts sets a session lock_timeout of 5s, which survives the embedded
COMMIT. CREATE INDEX CONCURRENTLY waits on every concurrent write transaction in
the database — not only ones touching this table — so on a busy database the
build is cancelled with 55P03 and leaves an INVALID index. The retry then
replays the file, IF NOT EXISTS skips the invalid index, and DROP INDEX removes
the only working index on provider_id. The migration journals as applied and
exits 0 with provider_id unindexed and uniqueness unenforced, reopening the
cross-tenant provider resolution this migration exists to close.
Adds SET lock_timeout = 0 around the concurrent statements, a pre-drop of the
target index name so a replay rebuilds rather than skips, and restores the 5s
timeout afterwards. Verified by stranding an INVALID index and replaying: the
end state is a valid unique index with uniqueness enforced.
Also corrects the sso() comment that claimed domainVerified confines linking to
matching email domains. link-account.mjs blocks on
`!isTrustedProvider && !userInfo.emailVerified`, so an IdP asserting
email_verified links regardless of domain — the flag narrows nothing on its own.1 parent 33e2cee commit afd7e27
4 files changed
Lines changed: 38 additions & 52 deletions
File tree
- apps/sim
- ee/sso/components
- lib/auth
- packages/db/migrations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 51 | + | |
56 | 52 | | |
57 | 53 | | |
58 | 54 | | |
| |||
257 | 253 | | |
258 | 254 | | |
259 | 255 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | 256 | | |
285 | 257 | | |
286 | 258 | | |
| |||
359 | 331 | | |
360 | 332 | | |
361 | 333 | | |
362 | | - | |
363 | | - | |
364 | | - | |
| 334 | + | |
365 | 335 | | |
366 | 336 | | |
367 | 337 | | |
| |||
499 | 469 | | |
500 | 470 | | |
501 | 471 | | |
502 | | - | |
503 | | - | |
504 | 472 | | |
505 | 473 | | |
506 | 474 | | |
| |||
554 | 522 | | |
555 | 523 | | |
556 | 524 | | |
557 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
558 | 529 | | |
559 | 530 | | |
560 | 531 | | |
| |||
908 | 879 | | |
909 | 880 | | |
910 | 881 | | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | | - | |
| 882 | + | |
915 | 883 | | |
916 | 884 | | |
917 | 885 | | |
| |||
942 | 910 | | |
943 | 911 | | |
944 | 912 | | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
| 913 | + | |
949 | 914 | | |
950 | 915 | | |
951 | 916 | | |
| |||
956 | 921 | | |
957 | 922 | | |
958 | 923 | | |
959 | | - | |
960 | | - | |
961 | | - | |
962 | | - | |
963 | 924 | | |
964 | 925 | | |
965 | 926 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
145 | 153 | | |
146 | 154 | | |
147 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1113 | 1113 | | |
1114 | 1114 | | |
1115 | 1115 | | |
1116 | | - | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
1120 | 1124 | | |
1121 | 1125 | | |
1122 | 1126 | | |
| |||
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
39 | 50 | | |
40 | 51 | | |
41 | 52 | | |
42 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
0 commit comments