Commit f547b22
fix: collision-safe url_normalized backfill in saved export
The keyset index from migration 0058 changes the implicit row order of
backfillUrlNormalized's unordered SELECT, so a different one of two same-URL
duplicate saves gets keyed. exportNativeSaves then processed the still-null
duplicate first and its UPDATE collided with the already-keyed row on the
unique (user_did, url_normalized) index, failing backing-enable.spec.ts.
- Make the export's url_normalized UPDATE collision-safe (NOT EXISTS guard),
matching the documented intent of backfillUrlNormalized; the loop's
alreadyBacked guard still collapses the duplicate to a single member.
- Order backfillUrlNormalized's SELECT by id so which duplicate gets keyed is
deterministic instead of depending on the query planner's index choice.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent b2f2489 commit f547b22
1 file changed
Lines changed: 13 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
141 | 143 | | |
142 | 144 | | |
143 | 145 | | |
| |||
267 | 269 | | |
268 | 270 | | |
269 | 271 | | |
270 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
271 | 277 | | |
272 | | - | |
273 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
274 | 283 | | |
275 | 284 | | |
276 | 285 | | |
| |||
0 commit comments