From c81f3d9c612ee5e210516a842db1057f566c8c5e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 16 Oct 2021 20:37:16 -0400 Subject: [PATCH] add Capturing, Analysing, AnalysisSource, Recording, RecordingSource to Monitors --- db/zm_create.sql.in | 5 ++++ db/zm_update-1.37.3.sql | 60 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 db/zm_update-1.37.3.sql diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 5cf6d3573..328dca6b7 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -449,6 +449,10 @@ CREATE TABLE `Monitors` ( `StorageId` smallint(5) unsigned default 0, `Type` enum('Local','Remote','File','Ffmpeg','Libvlc','cURL','WebSite','NVSocket','VNC') NOT NULL default 'Local', `Function` enum('None','Monitor','Modect','Record','Mocord','Nodect') NOT NULL default 'Monitor', + `Capturing` enum('None','Ondemand', 'Always') NOT NULL default 'Always', + `Analysing` enum('None','Always') NOT NULL default 'Always', + `AnalysisSource` enum('Primary','Secondary') NOT NULL DEFAULT 'Primary', + `Recording` enum('None', 'OnMotion', 'Always') NOT NULL default 'Always', `Enabled` tinyint(3) unsigned NOT NULL default '1', `DecodingEnabled` tinyint(3) unsigned NOT NULL default '1', `LinkedMonitors` varchar(255), @@ -487,6 +491,7 @@ CREATE TABLE `Monitors` ( `OutputContainer` enum('auto','mp4','mkv'), `EncoderParameters` TEXT, `RecordAudio` TINYINT NOT NULL DEFAULT '0', + `RecordingSource` enum('Primary','Secondary','Both') NOT NULL DEFAULT 'Primary', `RTSPDescribe` tinyint(1) unsigned, `Brightness` mediumint(7) NOT NULL default '-1', `Contrast` mediumint(7) NOT NULL default '-1', diff --git a/db/zm_update-1.37.3.sql b/db/zm_update-1.37.3.sql new file mode 100644 index 000000000..2db14e593 --- /dev/null +++ b/db/zm_update-1.37.3.sql @@ -0,0 +1,60 @@ + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Monitors' + AND column_name = 'Capturing' + ) > 0, +"SELECT 'Column Capturing already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `Capturing` enum('None','Ondemand', 'Always') NOT NULL default 'Always' AFTER `Function`" +)); + +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 = 'Analysing' + ) > 0, +"SELECT 'Column Analysing already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `Analysing` enum('None','Always') NOT NULL default 'Always'" +)); + +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 = 'AnalysisSource' + ) > 0, +"SELECT 'Column AnalysisSource already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `AnalysisSource` enum('Primary','Secondary') NOT NULL DEFAULT 'Primary' AFTER `Analysing`" +)); + +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 = 'Recording' + ) > 0, +"SELECT 'Column Recording already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `Recording` enum('None', 'OnMotion', 'Always') NOT NULL default 'Always'" +)); + +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 = 'RecordingSource' + ) > 0, +"SELECT 'Column RecordingSource already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `RecordingSource` enum('Primary','Secondary','Both') NOT NULL DEFAULT 'Primary' AFTER `RecordAudio`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt;