diff --git a/PARTITIONING.md b/PARTITIONING.md index 632e595..c82374b 100644 --- a/PARTITIONING.md +++ b/PARTITIONING.md @@ -62,6 +62,12 @@ System state can be monitored via the `partitions.monitoring` view. SELECT * FROM partitions.monitoring; ``` +### Versioning +To check the installed version of the partitioning solution: +```sql +SELECT * FROM partitions.version ORDER BY installed_at DESC LIMIT 1; +``` + ### Least Privilege Access (`zbx_monitor`) For monitoring purposes, it is recommended to create a dedicated user with read-only access to the monitoring view. diff --git a/postgresql/procedures/00_partitions_init.sql b/postgresql/procedures/00_partitions_init.sql index ea19270..b9664ea 100644 --- a/postgresql/procedures/00_partitions_init.sql +++ b/postgresql/procedures/00_partitions_init.sql @@ -15,6 +15,17 @@ CREATE TABLE IF NOT EXISTS partitions.config ( PRIMARY KEY (table_name) ); +-- Table to track installed version of the partitioning solution +CREATE TABLE IF NOT EXISTS partitions.version ( + version text PRIMARY KEY, + installed_at timestamp with time zone DEFAULT now(), + description text +); + +-- Set initial version +INSERT INTO partitions.version (version, description) VALUES ('1.0', 'Initial release') +ON CONFLICT (version) DO NOTHING; + -- Default configuration for Zabbix tables (adjust as needed) -- History tables: Daily partitions, keep 30 days INSERT INTO partitions.config (table_name, period, keep_history) VALUES