add update file for MQTT columns

This commit is contained in:
Isaac Connor 2021-12-29 13:19:50 -05:00
parent 2efabe5c10
commit 1f0f980e38
1 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,37 @@
--
-- Update Monitors table to have a MQTT_Enabled Column
--
SELECT 'Checking for MQTT_Enabled in Monitors';
SET @s = (SELECT IF(
(SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'Monitors'
AND table_schema = DATABASE()
AND column_name = 'MQTT_Enabled'
) > 0,
"SELECT 'Column MQTT_Enabled already exists in Monitors'",
"ALTER TABLE Monitors ADD COLUMN `MQTT_Enabled` BOOLEAN NOT NULL DEFAULT false AFTER `Importance`"
));
PREPARE stmt FROM @s;
EXECUTE stmt;
--
-- Update Monitors table to have a MQTT_Subscriptions Column
--
SELECT 'Checking for MQTT_Subscriptions in Monitors';
SET @s = (SELECT IF(
(SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'Monitors'
AND table_schema = DATABASE()
AND column_name = 'MQTT_Subscriptions'
) > 0,
"SELECT 'Column MQTT_Subscriptions already exists in Monitors'",
"ALTER TABLE Monitors ADD COLUMN `MQTT_Subscriptions` varchar(255) NOT NULL default '' AFTER `MQTT_Enabled`"
));
PREPARE stmt FROM @s;
EXECUTE stmt;