From 1fe421ed9d1b540c8a23b430ec7f4582cc98c774 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Nov 2017 14:22:12 -0800 Subject: [PATCH] add DiskSpace columns to Monitors --- db/zm_create.sql.in | 5 ++++ db/zm_update-1.31.14.sql | 59 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index ea37d9ffa..7a394c7be 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -435,10 +435,15 @@ CREATE TABLE `Monitors` ( `CaptureFPS` DECIMAL(10,2) NOT NULL default 0, `AnalysisFPS` DECIMAL(5,2) NOT NULL default 0, `TotalEvents` int(10) unsigned, + `TotalEventDiskSpace` bigint unsigned, `HourEvents` int(10) unsigned, + `HourEventDiskSpace` bigint unsigned, `DayEvents` int(10) unsigned, + `DayEventDiskSpace` bigint unsigned, `WeekEvents` int(10) unsigned, + `WeekEventDiskSpace` bigint unsigned, `MonthEvents` int(10) unsigned, + `MonthEventDiskSpace` bigint unsigned, PRIMARY KEY (`Id`) ) ENGINE=@ZM_MYSQL_ENGINE@; diff --git a/db/zm_update-1.31.14.sql b/db/zm_update-1.31.14.sql index f6c2af314..859b28162 100644 --- a/db/zm_update-1.31.14.sql +++ b/db/zm_update-1.31.14.sql @@ -11,6 +11,18 @@ SET @s = (SELECT IF( PREPARE stmt FROM @s; EXECUTE stmt; +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'TotalEventDiskSpace' + ) > 0, +"SELECT 'Column TotalEventDiskSpace already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `TotalEventDiskSpace` BIGINT AFTER `TotalEvents`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + SET @s = (SELECT IF( (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name = 'Monitors' @@ -21,6 +33,18 @@ SET @s = (SELECT IF( )); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'HourEventDiskSpace' + ) > 0, +"SELECT 'Column HourEventDiskSpace already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `HourEventDiskSpace` BIGINT AFTER `HourEvents`" +)); + PREPARE stmt FROM @s; EXECUTE stmt; @@ -37,6 +61,17 @@ SET @s = (SELECT IF( PREPARE stmt FROM @s; EXECUTE stmt; +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'DayEventDiskSpace' + ) > 0, +"SELECT 'Column DayEventDiskSpace already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `DayEventDiskSpace` BIGINT AFTER `DayEvents`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; SET @s = (SELECT IF( (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name = 'Monitors' @@ -53,7 +88,18 @@ EXECUTE stmt; SET @s = (SELECT IF( (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() AND table_name = 'Monitors' - AND column_name = 'WeekEvents' + AND column_name = 'WeekEventDiskSpace' + ) > 0, +"SELECT 'Column WeekEventDiskSpace already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `WeekEventDiskSpace` BIGINT AFTER `WeekEvents`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'MonthEvents' ) > 0, "SELECT 'Column MonthEvents already exists in Monitors'", "ALTER TABLE `Monitors` ADD `MonthEvents` INT(10) AFTER `WeekEvents`" @@ -63,3 +109,14 @@ SET @s = (SELECT IF( PREPARE stmt FROM @s; EXECUTE stmt; +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'MonthEventDiskSpace' + ) > 0, +"SELECT 'Column MonthEventDiskSpace already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `MonthEventDiskSpace` BIGINT AFTER `MonthEvents`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt;