From 8c9a7f3367fe8c36219e1d3c2a10936e0273fd4a Mon Sep 17 00:00:00 2001 From: zvx-echo6 Date: Sun, 7 Jun 2026 00:37:09 +0000 Subject: [PATCH] v0.10.3.1: soft-disable state_511_atis* adapters instead of DELETE (FK blocked v0.10.3 migration) The v0.10.3 deploy halted at migration 032 because events_adapter_fkey (ON DELETE RESTRICT) blocked the DELETE: 66 state_511_atis events + 2379 state_511_atis_cameras events still reference the adapter rows. Matt's explicit rule was 'preserve historical events as a record', so the rows must stay -- they just become soft-deleted tombstones. Add 033_soft_disable_state_511_atis_adapters.sql: UPDATE config.adapters SET enabled = false, paused_at = NOW() WHERE name IN ('state_511_atis', 'state_511_atis_cameras'); Effect: list_enabled_adapters() filters on enabled=true, so on next supervisor restart these rows fall out of the startup set naturally. The 2 'Unknown adapter type' WARNING lines from v0.10.3's degraded deploy go away. Amend 032's header comment to note the supersession (don't delete 032 -- the migration ledger is append-only). No code change. 998/1 tests still green. Dry-run of 033 against live db returns UPDATE 2 cleanly. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../032_remove_state_511_atis_adapters.sql | 7 ++++++ ...3_soft_disable_state_511_atis_adapters.sql | 24 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 sql/migrations/033_soft_disable_state_511_atis_adapters.sql diff --git a/sql/migrations/032_remove_state_511_atis_adapters.sql b/sql/migrations/032_remove_state_511_atis_adapters.sql index 2a0fbb6..59fd615 100644 --- a/sql/migrations/032_remove_state_511_atis_adapters.sql +++ b/sql/migrations/032_remove_state_511_atis_adapters.sql @@ -1,6 +1,13 @@ -- v0.10.3: rip out state_511_atis + state_511_atis_cameras (Castle Rock legacy -- shape EOL; superseded by itd_511 + itd_511_cameras from migration 031 / v0.10.0). -- +-- v0.10.3.1: Superseded by 033_soft_disable_state_511_atis_adapters.sql due to +-- the FK constraint events_adapter_fkey ON DELETE RESTRICT. Historical events +-- preserve referential integrity; the rows remain as soft-deleted tombstones +-- (enabled=false + paused_at=NOW()). This file is preserved as part of the +-- append-only migration ledger; running it on a fresh database still throws +-- the same FK error if any state_511_atis* events exist. +-- -- Idempotent: the DELETE succeeds whether the rows are present or not. Historical -- events in public.events stay (preserved as historical record per Matt's call); -- only the config.adapters rows that would otherwise be hot-reloaded into the diff --git a/sql/migrations/033_soft_disable_state_511_atis_adapters.sql b/sql/migrations/033_soft_disable_state_511_atis_adapters.sql new file mode 100644 index 0000000..edfa246 --- /dev/null +++ b/sql/migrations/033_soft_disable_state_511_atis_adapters.sql @@ -0,0 +1,24 @@ +-- v0.10.3.1: soft-disable state_511_atis + state_511_atis_cameras (Castle Rock +-- legacy shape EOL; superseded by itd_511 + itd_511_cameras from migration 031). +-- +-- The original v0.10.3 plan was a hard DELETE in 032, but events_adapter_fkey +-- (ON DELETE RESTRICT) blocked it: 66 state_511_atis events + 2379 +-- state_511_atis_cameras events still reference the adapter rows. Matt's +-- explicit rule was "preserve historical events as a record", so the rows must +-- stay -- they just become soft-deleted tombstones. +-- +-- Effect on the supervisor: list_enabled_adapters() filters on enabled=true, +-- so these rows fall out of the startup adapter set naturally. The +-- "Unknown adapter type" WARNING lines from v0.10.3's degraded deploy go away +-- on the next supervisor restart. +-- +-- Idempotent: re-running this on already-disabled rows updates paused_at to +-- the current timestamp, which is harmless (the row was already disabled). +-- +-- Note: cursors.db cleanup ran as part of the v0.10.3 deploy already; not +-- repeated here. + +UPDATE config.adapters +SET enabled = false, + paused_at = NOW() +WHERE name IN ('state_511_atis', 'state_511_atis_cameras');