From 85529efffcf79181c15bcd8a25954edd4955328c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 22 Oct 2014 10:31:23 -0400 Subject: [PATCH] check for existence of the columns beefore trying to add them --- db/zm_update-1.26.0.sql | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/db/zm_update-1.26.0.sql b/db/zm_update-1.26.0.sql index 28f8685ef..9986c029b 100644 --- a/db/zm_update-1.26.0.sql +++ b/db/zm_update-1.26.0.sql @@ -1,3 +1,27 @@ -ALTER TABLE `Monitors` ADD `Colours` TINYINT UNSIGNED NOT NULL DEFAULT '1' AFTER `Height`; -ALTER TABLE `Monitors` ADD `Deinterlacing` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `Orientation`; +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = 'Monitors' + AND table_schema = DATABASE() + AND column_name = 'Colours' + ) > 0, +"SELECT 'Column Colours exists in Monitors'", +"ALTER TABLE `Monitors` ADD `Colours` TINYINT UNSIGNED NOT NULL DEFAULT '1' AFTER `Height`" +)); +PREPARE stmt FROM @s; +EXECUTE stmt; + +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = 'Monitors' + AND table_schema = DATABASE() + AND column_name = 'Deinterlacing' + ) > 0, +"SELECT 'Column Deinterlacing exists in Monitors'", +"ALTER TABLE `Monitors` ADD `Deinterlacing` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `Orientation`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt;