From 3361abaa923084f3821bbf14bea14228059088a6 Mon Sep 17 00:00:00 2001 From: malice Date: Mon, 15 Jun 2026 22:02:02 -0600 Subject: [PATCH] v0.14.5: migration 042 re-asserts central ownership of config.monitoring_areas (#111) Append idempotent ALTER ... OWNER TO central for the table + SERIAL sequence so fresh installs are self-healing; prod already patched inline during v0.14.0. Adds whitespace-insensitive static-check assertions. Co-Authored-By: Claude Opus 4.8 (1M context) --- sql/migrations/042_monitoring_area_to_multi_areas.sql | 10 ++++++++++ tests/test_migration_042.py | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/sql/migrations/042_monitoring_area_to_multi_areas.sql b/sql/migrations/042_monitoring_area_to_multi_areas.sql index 77d2754..1fd109f 100644 --- a/sql/migrations/042_monitoring_area_to_multi_areas.sql +++ b/sql/migrations/042_monitoring_area_to_multi_areas.sql @@ -46,3 +46,13 @@ WHERE id = true AND monitor_east IS NOT NULL AND monitor_west IS NOT NULL ON CONFLICT (name) DO NOTHING; + +-- Ownership fix (v0.14.5). During the v0.14.0 prod deploy (2026-06-12) this +-- migration was applied as `sudo -u postgres`, so the table + its SERIAL +-- sequence ended up owned by postgres while the `central` app role expects +-- ownership-based access (it could read but not manage the new config table). +-- We patched prod inline with these same ALTERs; making them part of the file +-- keeps fresh installs self-healing. Idempotent: a no-op when already owned by +-- central. (See central-manual-migration-owner-role.) +ALTER TABLE config.monitoring_areas OWNER TO central; +ALTER SEQUENCE config.monitoring_areas_id_seq OWNER TO central; diff --git a/tests/test_migration_042.py b/tests/test_migration_042.py index 3a1902f..182cf67 100644 --- a/tests/test_migration_042.py +++ b/tests/test_migration_042.py @@ -38,3 +38,10 @@ def test_does_not_drop_old_columns_in_v0_14_0(): upper = _NORM.upper() assert "DROP COLUMN" not in upper assert "DROP TABLE" not in upper + + +def test_grants_table_and_sequence_ownership_to_central(): + # v0.14.5: applied-as-postgres left the table/sequence postgres-owned; the + # file now re-asserts central ownership so fresh installs are self-healing. + assert "ALTER TABLE config.monitoring_areas OWNER TO central" in _NORM + assert "ALTER SEQUENCE config.monitoring_areas_id_seq OWNER TO central" in _NORM