mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-10-23 06:48:24 -04:00
check for existence of the columns beefore trying to add them
This commit is contained in:
1 parent
e23c756ca4
commit
85529efffc
1 file changed
+26
-2
+26
-2
@@ -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;
|
||||
Reference in new issue
Block a user