From 60fb654a4701c295a37df00572b5d3a0c7f1a60c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 27 Oct 2017 09:57:41 -0700 Subject: [PATCH] rough in the MontageLayouts table --- db/zm_create.sql.in | 8 +++++ db/zm_update-1.31.11.sql | 69 ++++++++++++++++++++++++++++++++++++++++ db/zm_update-1.31.12.sql | 23 ++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 db/zm_update-1.31.11.sql create mode 100644 db/zm_update-1.31.12.sql diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 01176eb43..2cff3c576 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -762,6 +762,14 @@ CREATE TABLE Maps ( `ParentId` int(1) unsigned, PRIMARY KEY (`Id`) ); + +CREATE TABLE MontageLayouts ( + `Id` int(10) unsigned NOT NULL auto_increment, + `Name` TEXT NOT NULL, + `Positions` JSON, + PRIMARY KEY (`Id`) +); + -- -- Apply the initial configuration -- diff --git a/db/zm_update-1.31.11.sql b/db/zm_update-1.31.11.sql new file mode 100644 index 000000000..de17d85d9 --- /dev/null +++ b/db/zm_update-1.31.11.sql @@ -0,0 +1,69 @@ +-- +-- Add UpdateDiskSpace action to Filters +-- + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Filters' + AND column_name = 'UpdateDiskSpace' + ) > 0, +"SELECT 'Column UpdateDiskSpace already exists in Filters'", +"ALTER TABLE Filters ADD `UpdateDiskSpace` tinyint(3) unsigned NOT NULL default '0' AFTER `AutoDelete`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; +-- +-- Update Logs table to have some Indexes +-- +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.STATISTICS + WHERE table_name = 'Logs' + AND table_schema = DATABASE() + AND index_name = 'Logs_TimeKey_idx' + ) > 0, +"SELECT 'Logs_TimeKey_idx already exists on Logs table'", +"CREATE INDEX `Logs_TimeKey_idx` ON `Logs` (`TimeKey`)" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.STATISTICS + WHERE table_name = 'Logs' + AND table_schema = DATABASE() + AND index_name = 'Logs_Level_idx' + ) > 0, +"SELECT 'Logs_Level_idx already exists on Logs table'", +"CREATE INDEX `Logs_Level_idx` ON `Logs` (`Level`)" +)); + +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 = 'OutputCodec' + ) > 0, +"SELECT 'Column OutputCodec already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `OutputCodec` enum('h264','mjpeg') AFTER `VideoWriter`" +)); + +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 = 'OutputContainer' + ) > 0, +"SELECT 'Column OutputContainer already exists in Monitors'", +"ALTER TABLE `Monitors` ADD `OutputContainer` enum('mp4','mkv') AFTER `OutputCodec`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; diff --git a/db/zm_update-1.31.12.sql b/db/zm_update-1.31.12.sql new file mode 100644 index 000000000..a267728f5 --- /dev/null +++ b/db/zm_update-1.31.12.sql @@ -0,0 +1,23 @@ +-- +-- This adds Manufacturers and Models +-- + +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.TABLES + WHERE table_name = 'MontageLayouts' + AND table_schema = DATABASE() + ) > 0, + "SELECT 'MontageLayouts table exists'", + " + CREATE TABLE MontageLayouts ( + `Id` int(10) unsigned NOT NULL auto_increment, + `Name` TEXT NOT NULL, + `Positions` JSON, + PRIMARY KEY (`Id`) +); +" + )); + +PREPARE stmt FROM @s; +EXECUTE stmt;