2017-12-19 01:52:26 +08:00
|
|
|
alter table Events modify Id int(10) unsigned;
|
|
|
|
alter table Events DROP Primary key;
|
|
|
|
alter table Events Add Primary key(Id);
|
2017-12-19 02:05:04 +08:00
|
|
|
alter table Events modify Id int(10) unsigned auto_increment;
|
2017-12-19 01:52:26 +08:00
|
|
|
|
2018-02-19 00:01:33 +08:00
|
|
|
SET @s = (SELECT IF(
|
|
|
|
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
|
|
|
AND table_name = 'Storage'
|
|
|
|
AND column_name = 'DiskSpace'
|
|
|
|
) > 0,
|
|
|
|
"SELECT 'Column DiskSpace already exists in Storage'",
|
|
|
|
"ALTER TABLE Storage ADD `DiskSpace` BIGINT default null AFTER `Type`"
|
|
|
|
));
|
|
|
|
|
|
|
|
PREPARE stmt FROM @s;
|
|
|
|
EXECUTE stmt;
|
|
|
|
|
2017-12-19 01:52:26 +08:00
|
|
|
SET @s = (SELECT IF(
|
|
|
|
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
|
|
|
AND table_name = 'Storage'
|
|
|
|
AND column_name = 'Scheme'
|
|
|
|
) > 0,
|
|
|
|
"SELECT 'Column Scheme already exists in Storage'",
|
2017-12-19 02:05:04 +08:00
|
|
|
"ALTER TABLE Storage ADD `Scheme` enum('Deep','Medium','Shallow') NOT NULL default 'Medium' AFTER `DiskSpace`"
|
2017-12-19 01:52:26 +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 = 'Events'
|
2017-12-19 02:05:04 +08:00
|
|
|
AND column_name = 'Scheme'
|
2017-12-19 01:52:26 +08:00
|
|
|
) > 0,
|
2017-12-19 02:05:04 +08:00
|
|
|
"SELECT 'Column Scheme already exists in Events'",
|
|
|
|
"ALTER TABLE Events ADD `Scheme` enum('Deep','Medium','Shallow') NOT NULL default 'Deep' AFTER `DiskSpace`"
|
2017-12-19 01:52:26 +08:00
|
|
|
));
|
|
|
|
|
|
|
|
PREPARE stmt FROM @s;
|
|
|
|
EXECUTE stmt;
|