fix(migration): guard 033 channel_database backfill — v4.11.5 hotfix (#3657)#3658
Conversation
…ce (#3657) Regression introduced by #3640 (v4.11.4): removing channel_database from migration 021's sourceId-add left migration 033's `UPDATE channel_database SET sourceId ...` referencing a column that no longer exists. On PostgreSQL — which re-runs every migration on every boot — and on fresh installs, 033 then crashed during DB init with `column "sourceId" does not exist`, so the app couldn't start. The crash only triggered when at least one source was registered (the backfill is gated on `sources.length > 0`); the CI fixtures have no sources, which is why it slipped through. Fix: guard the channel_database backfill on the legacy `sourceId` column still existing (PRAGMA table_info on SQLite, information_schema on PG/MySQL). channel_database is global-by-design (063 drops sourceId), so on current databases the column is absent and the backfill is correctly a no-op; on a mid-upgrade DB where the column is still present it still runs. Adds 033_per_source_permissions.test.ts: reproduces #3657 (source present + channel_database without sourceId → no throw), confirms back-compat backfill when the column is present, and the no-sources case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JEaCGwY9Wz8jeV4e22GW4
Bumps all five version files 4.11.4 -> 4.11.5. v4.11.4 was retracted because migration 033 crashed Postgres/fresh-install startup (#3657); this release carries the fix. 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: fix(migration): guard 033 channel_database backfill — v4.11.5 hotfix
SummaryThis is a well-targeted hotfix. The root cause analysis is accurate, the fix is surgical and correct, and the test coverage is solid. A few minor observations below. Migration 033 Changes (
|
System Test ResultsMeshMonitor System Test ResultsTest Run: 2026-06-22 17:03:27 EDT ❌ Overall Result: FAILEDAborted on first failing test (fail-fast mode). Remaining tests skipped. Failed Test
|
System Test ResultsMeshMonitor System Test ResultsTest Run: 2026-06-22 17:12:46 EDT ❌ Overall Result: FAILEDAborted on first failing test (fail-fast mode). Remaining tests skipped. Failed Test
|
🚨 Hotfix for #3657 — v4.11.4 broke Postgres / fresh-install startup
v4.11.4 has been retracted (unpublished). This PR fixes the regression and bumps to v4.11.5.
Root cause
#3640 (in v4.11.4) removed
channel_databasefrom migration 021'ssourceId-add to stop the PG boot-loop (#3639). But migration 033 still runsUPDATE channel_database SET sourceId .... Migration order is 021 (add) → 033 (update) → 063 (drop). On PostgreSQL — which re-runs every migration on every boot — v4.11.3 worked because 021 re-added the column before 033 ran. With 021 no longer adding it, 033 crashes during DB init:This also breaks fresh installs on all backends (021 → 033 with no column). It only triggers when ≥1 source is registered (the backfill is gated on
sources.length > 0) — the CI fixtures have no sources, which is exactly why it slipped through.Fix
Guard migration 033's
channel_databasebackfill on the legacysourceIdcolumn still existing —PRAGMA table_info(SQLite),information_schema.columns(PG/MySQL).channel_databaseis global-by-design (063 dropssourceId), so on current DBs the column is absent and the backfill is correctly a no-op; on a mid-upgrade DB where it's still present, it still runs.Testing
033_per_source_permissions.test.ts— reproduces [BUG] Failed to initialize PostgreSQL/MySQL: error: column "sourceId" does not exist #3657 (source present +channel_databasewithoutsourceId→ no throw; the previous code threw "no such column"), confirms the back-compat backfill still runs when the column exists, and the no-sources case.tsc -p tsconfig.server.jsonclean.Version
🤖 Generated with Claude Code