fix: automatic column additions, permissions grants and docs updates for seamless upgrades

This commit is contained in:
Maksym Buz
2026-05-05 17:56:57 +00:00
parent 345495eaf5
commit 96c087b920
6 changed files with 75 additions and 25 deletions

View File

@@ -74,11 +74,24 @@ BEGIN
END $$;
-- ==========================================================================
-- IMPORTANT: If the Zabbix Server connects with a non-superuser (e.g., 'zabbix'),
-- that user MUST have access to the partitions schema for the housekeeper trigger
-- to work. Without these GRANTs, every INSERT into housekeeper will FAIL.
-- Uncomment and adjust the username below:
-- IMPORTANT: To ensure the Zabbix Server can insert into the housekeeper
-- table without permission issues, we automatically grant access to the
-- partitions schema to the owner of the housekeeper table.
-- ==========================================================================
-- GRANT USAGE ON SCHEMA partitions TO zabbix;
-- GRANT SELECT ON partitions.config TO zabbix;
DO $$
DECLARE
v_owner text;
BEGIN
SELECT pg_get_userbyid(c.relowner) INTO v_owner
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relname = 'housekeeper' AND pg_table_is_visible(c.oid);
IF v_owner IS NOT NULL THEN
EXECUTE format('GRANT USAGE ON SCHEMA partitions TO %I', v_owner);
EXECUTE format('GRANT SELECT ON partitions.config TO %I', v_owner);
RAISE NOTICE 'Granted partitions schema permissions to housekeeper owner: %', v_owner;
ELSE
RAISE WARNING 'housekeeper table not found, could not grant permissions automatically!';
END IF;
END $$;