2017-10-25 05:21:25 +08:00
|
|
|
--
|
|
|
|
-- Add Type column to Storage
|
|
|
|
--
|
|
|
|
|
|
|
|
SET @s = (SELECT IF(
|
|
|
|
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
|
|
|
AND table_name = 'Servers'
|
|
|
|
AND column_name = 'Status'
|
|
|
|
) > 0,
|
|
|
|
"SELECT 'Column Status already exists in Servers'",
|
|
|
|
"ALTER TABLE Servers ADD `Status` enum('Unknown','NotRunning','Running') NOT NULL default 'Unknown' AFTER `State_Id`"
|
|
|
|
));
|
|
|
|
|
|
|
|
PREPARE stmt FROM @s;
|
|
|
|
EXECUTE stmt;
|
|
|
|
|
|
|
|
SET @s = (SELECT IF(
|
|
|
|
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
|
|
|
AND table_name = 'Servers'
|
2017-10-25 06:13:02 +08:00
|
|
|
AND column_name = 'CpuLoad'
|
2017-10-25 05:21:25 +08:00
|
|
|
) > 0,
|
2017-10-25 06:13:02 +08:00
|
|
|
"SELECT 'Column CpuLoad already exists in Servers'",
|
|
|
|
"ALTER TABLE Servers ADD `CpuLoad` DECIMAL(5,1) default NULL AFTER `Status`"
|
2017-10-25 05:21:25 +08:00
|
|
|
));
|
|
|
|
|
|
|
|
PREPARE stmt FROM @s;
|
|
|
|
EXECUTE stmt;
|
|
|
|
|
|
|
|
SET @s = (SELECT IF(
|
|
|
|
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
|
|
|
AND table_name = 'Servers'
|
|
|
|
AND column_name = 'TotalMem'
|
|
|
|
) > 0,
|
|
|
|
"SELECT 'Column TotalMem already exists in Servers'",
|
2017-10-25 06:13:02 +08:00
|
|
|
"ALTER TABLE Servers ADD `TotalMem` bigint unsigned default null AFTER `CpuLoad`"
|
2017-10-25 05:21:25 +08:00
|
|
|
));
|
|
|
|
|
|
|
|
PREPARE stmt FROM @s;
|
|
|
|
EXECUTE stmt;
|
|
|
|
|
|
|
|
SET @s = (SELECT IF(
|
|
|
|
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
|
|
|
AND table_name = 'Servers'
|
|
|
|
AND column_name = 'FreeMem'
|
|
|
|
) > 0,
|
|
|
|
"SELECT 'Column FreeMem already exists in Servers'",
|
|
|
|
"ALTER TABLE Servers ADD `FreeMem` bigint unsigned default null AFTER `TotalMem`"
|
|
|
|
));
|
|
|
|
|
|
|
|
PREPARE stmt FROM @s;
|
|
|
|
EXECUTE stmt;
|
|
|
|
|
|
|
|
SET @s = (SELECT IF(
|
|
|
|
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
|
|
|
AND table_name = 'Servers'
|
|
|
|
AND column_name = 'TotalSwap'
|
|
|
|
) > 0,
|
|
|
|
"SELECT 'Column TotalSwap already exists in Servers'",
|
|
|
|
"ALTER TABLE Servers ADD `TotalSwap` bigint unsigned default null AFTER `FreeMem`"
|
|
|
|
));
|
|
|
|
|
|
|
|
PREPARE stmt FROM @s;
|
|
|
|
EXECUTE stmt;
|
|
|
|
|
|
|
|
SET @s = (SELECT IF(
|
|
|
|
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
|
|
|
AND table_name = 'Servers'
|
|
|
|
AND column_name = 'FreeSwap'
|
|
|
|
) > 0,
|
|
|
|
"SELECT 'Column FreeSwap already exists in Servers'",
|
|
|
|
"ALTER TABLE Servers ADD `FreeSwap` bigint unsigned default null AFTER `TotalSwap`"
|
|
|
|
));
|
|
|
|
|
|
|
|
PREPARE stmt FROM @s;
|
|
|
|
EXECUTE stmt;
|