Commit 330fdd6
authored
fix(db): give the anomaly-alert dedup claims their own alert_dedup_claims table (#8985)
runAnomalyAlerts in src/review/alerts.ts writes per-hour dedup claims shaped
(id, project, target_id, notification_key, status) with
ON CONFLICT(project, target_id, notification_key) DO NOTHING, but pointed those
raw INSERTs at notification_deliveries -- the migrated badge read-model (0031),
whose columns are dedup_key/channel/recipient_login/... with a UNIQUE(dedup_key,
channel) index. None of the claim columns nor the ON CONFLICT target exist there.
runAnomalyAlerts has no callers yet, so this hasn't fired, but the moment it is
wired to a cron path every Discord-notify invocation throws at the first INSERT.
Add migration 0181 creating a distinctly-named alert_dedup_claims table with the
(project, target_id, notification_key) unique index the port actually needs, and
point both claim inserts at it. Allowlist the table in check-schema-drift as a
raw-SQL-only feature table (alerts.ts accesses it via env.DB.prepare, not Drizzle).
A new test drives runAnomalyAlerts against the real migrated D1 (createTestEnv)
and asserts both claims land in alert_dedup_claims and a same-hour repeat is
throttled by the unique constraint -- proving the write path no longer collides.
Closes #8901
Co-authored-by: bitfathers94 <237535319+bitfathers94@users.noreply.github.com>1 parent 2f7104e commit 330fdd6
4 files changed
Lines changed: 60 additions & 6 deletions
File tree
- migrations
- scripts
- src/review
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
| |||
361 | 363 | | |
362 | 364 | | |
363 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
0 commit comments