refactor(procedures): rename init script and revert monitoring view
This commit is contained in:
@@ -21,7 +21,7 @@ This ensures that the partitioning scripts will work flawlessly, even in custom
|
||||
|
||||
The solution is divided into a series of SQL scripts that must be executed sequentially to set up the environment.
|
||||
|
||||
### 1. `00_partitions_init.sql`
|
||||
### 1. `00_schema_create.sql`
|
||||
* **Purpose:** Initializes the foundation for the partitioning system.
|
||||
* **Actions:**
|
||||
* Creates the isolated `partitions` schema to keep everything separate from Zabbix's own structure.
|
||||
|
||||
@@ -67,8 +67,8 @@ if [[ -f "$SQL_DIR/schema.sql" ]]; then
|
||||
cp "$SQL_DIR/schema.sql" ./init_scripts/01_00_schema.sql
|
||||
|
||||
# 1.1 Partitioning Infrastructure
|
||||
if [[ -f "../procedures/00_partitions_init.sql" ]]; then
|
||||
cp "../procedures/00_partitions_init.sql" ./init_scripts/01_10_partitions_init.sql
|
||||
if [[ -f "../procedures/00_schema_create.sql" ]]; then
|
||||
cp "../procedures/00_schema_create.sql" ./init_scripts/01_10_schema_create.sql
|
||||
fi
|
||||
if [[ -f "../procedures/01_maintenance.sql" ]]; then
|
||||
cp "../procedures/01_maintenance.sql" ./init_scripts/01_30_maintenance.sql
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
-- Creates a view to monitor partition status and sizes.
|
||||
-- ============================================================================
|
||||
|
||||
CREATE OR REPLACE VIEW partitions.monitoring AS
|
||||
DROP VIEW IF EXISTS partitions.monitoring;
|
||||
CREATE VIEW partitions.monitoring AS
|
||||
SELECT
|
||||
parent.relname AS parent_table,
|
||||
c.table_name,
|
||||
|
||||
@@ -55,7 +55,7 @@ If you are deploying Zabbix on a fresh database instance (like AWS RDS) rather t
|
||||
## Installation
|
||||
|
||||
The installation is performed by executing the SQL procedures in the following order:
|
||||
1. Initialize schema (`00_partitions_init.sql`).
|
||||
1. Initialize schema (`00_schema_create.sql`).
|
||||
2. Install maintenance procedures (`01_maintenance.sql`).
|
||||
3. Enable partitioning on tables (`02_enable_partitioning.sql`).
|
||||
4. Install monitoring views (`03_monitoring_view.sql`).
|
||||
@@ -70,7 +70,7 @@ DB_HOST="localhost" # Or your RDS endpoint
|
||||
DB_NAME="zabbix"
|
||||
DB_USER="zabbix"
|
||||
|
||||
for script in 00_partitions_init.sql 01_maintenance.sql 02_enable_partitioning.sql 03_monitoring_view.sql; do
|
||||
for script in 00_schema_create.sql 01_maintenance.sql 02_enable_partitioning.sql 03_monitoring_view.sql; do
|
||||
echo "Applying $script..."
|
||||
psql -h $DB_HOST -U $DB_USER -d $DB_NAME -f "$script"
|
||||
done
|
||||
@@ -247,6 +247,9 @@ GRANT USAGE ON SCHEMA partitions TO zbx_monitor;
|
||||
GRANT SELECT ON partitions.monitoring TO zbx_monitor;
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> If you ever apply updates to `03_monitoring_view.sql`, you should run the script as the `zabbix` database user (the original creator of the view). The script drops and recreates the view, so running it as `zabbix` ensures the view retains its ownership and preserves existing `GRANT` permissions for read-only users.
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### `auditlog` Table
|
||||
|
||||
Reference in New Issue
Block a user