Commit 44bcc2a
committed
fix: serialise mirror Date values in MariaDB-compatible format
Sequelize's default datetime format "YYYY-MM-DD HH:mm:ss.SSS +00:00"
includes a trailing "+00:00" offset that recent MariaDB strict mode
rejects with:
Incorrect datetime value: '2026-04-16 22:41:27.490 +00:00'
for column `cadt_mirror_test`.`audit`.`createdAt` at row 1
Every mirror write touching a DATE/DATETIME column was silently dropped
by the fire-and-forget safeMirrorDbHandler[V2]. This affected both V1
and V2 mirrors in production - the v2 live-api CI run exposed 59 such
errors but still passed because V2 test assertions only check
project/methodology-level records, not audit. V1 live-api verification
added in this PR surfaced the bug directly on the verified records
(projects.projectStatusDate, labels.creditingPeriodStartDate, etc.).
The fix is to set `timezone: '+00:00'` at the Sequelize constructor
level for both `mirror` and `v2Mirror` configs. At the constructor
level (unlike Model.init, where the option is silently ignored),
Sequelize converts Date values to UTC and emits the MariaDB-safe
"YYYY-MM-DD HH:MM:SS[.SSS]" format.
Also updates prepareMysqlMirrorV2's JSDoc to reflect that it does
throw (intentionally) when V1/V2 share a MIRROR_DB name - the earlier
"Never throws" claim was left over from before validateMirrorDbNames
was moved to fail-loud. Both callers (prepareV2Db and
startV2ReconnectBackfill) are wrapped in try/catch at the right level.1 parent 47481a0 commit 44bcc2a
2 files changed
Lines changed: 26 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
64 | 76 | | |
65 | 77 | | |
66 | 78 | | |
| |||
96 | 108 | | |
97 | 109 | | |
98 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
99 | 114 | | |
100 | 115 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
581 | 581 | | |
582 | 582 | | |
583 | 583 | | |
584 | | - | |
585 | | - | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
586 | 595 | | |
587 | 596 | | |
588 | 597 | | |
| |||
0 commit comments