test(migrations): guard against source-dependent migration crashes (#3657)#3661
Conversation
…3657) Post-incident regression guard. The migration suite only ever ran the full registry against a DB with ZERO sources, so the `if (sources.length > 0)` branch of every source-dependent migration went unexercised — exactly how #3657 shipped (migration 033's channel_database backfill crashed only when a source was present and the legacy sourceId column was absent). This replays the full SQLite migration registry and registers a source the moment the `sources` table exists (migration 020), so every later source-dependent migration runs its populated-source path. Verified to fail ("Migration 33 … no such column: sourceId") when 033's guard is removed, so a future 033-style regression is now caught in plain unit CI rather than only on the hardware system-test gate. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JEaCGwY9Wz8jeV4e22GW4
|
Claude finished @Yeraze's task —— View job PR Review: test(migrations): guard against source-dependent migration crashes
OverviewThis is a well-motivated regression guard. The incident description in both the PR body and the file header clearly explains the blind spot: the existing migration test always ran against a zero-source DB, so the Code QualityStrengths:
Potential issues:
Minor Nits
VerdictApprove with suggestions. The core approach is sound and catches the exact regression class described. The two most actionable suggestions are:
Neither is a blocker — this test is already a meaningful improvement over the prior zero-source-only coverage. |
Summary
Post-incident regression guard for #3657 (the v4.11.4 boot crash).
The blind spot: the migration suite only ever ran the full registry against a DB with zero sources (
createTestDb). Many migrations do source-dependent work behindif (sources.length > 0)— that whole branch was never exercised by unit CI, which is exactly how #3657 shipped: migration 033'sUPDATE channel_database SET sourceId …only runs when a source exists, and it crashed once #3640 stopped migration 021 from adding that column. The bug only surfaced on the hardware system-test gate (which had a source configured) — and that gate was itself unusable because the test node had bricked itself on the bad release.What this adds
A test that replays the full SQLite migration registry and registers a source the moment the
sourcestable exists (migration 020), so every subsequent source-dependent migration runs its populated-source path. Failures are labeled by migration number/name.Verification
main(033 guarded).Migration 33 (per_source_permissions) threw with a source registered: no such column: sourceId— the exact [BUG] Failed to initialize PostgreSQL/MySQL: error: column "sourceId" does not exist #3657 fingerprint.A future "033-style" missing-column-with-a-source regression now fails in plain unit CI instead of slipping to the hardware gate.
🤖 Generated with Claude Code