merge manufacturer update into existing zm_update-1.37.2 and then move it to .in
This commit is contained in:
parent
1fd99424bb
commit
9d71f1192a
|
@ -1,23 +1,4 @@
|
||||||
INSERT INTO Manufacturers VALUES (1, 'Acti');
|
INSERT INTO Manufacturers VALUES (1, 'Acti');
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A21');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A23');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A24');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A28');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A31');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A310');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A311');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A32');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A41');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A415');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A416');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A418');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A42');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A421');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A43');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A45');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A46');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A48');
|
|
||||||
INSERT INTO Models (ManufacturerId,Name) VALUES (1, 'A74');
|
|
||||||
INSERT INTO Manufacturers VALUES (2, 'Amcrest');
|
INSERT INTO Manufacturers VALUES (2, 'Amcrest');
|
||||||
INSERT INTO Manufacturers VALUES (3, 'Airlink101');
|
INSERT INTO Manufacturers VALUES (3, 'Airlink101');
|
||||||
INSERT INTO Manufacturers VALUES (4, 'Arecont Vision');
|
INSERT INTO Manufacturers VALUES (4, 'Arecont Vision');
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
SET @s = (SELECT IF(
|
|
||||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
|
||||||
AND table_name = 'Monitors'
|
|
||||||
AND column_name = 'ManufacturerId'
|
|
||||||
) > 0,
|
|
||||||
"SELECT 'Column ManufacturerId already exists in Monitors'",
|
|
||||||
"ALTER TABLE `Monitors` ADD `ManufacturerId` int(10) unsigned AFTER `StorageId`"
|
|
||||||
));
|
|
||||||
|
|
||||||
PREPARE stmt FROM @s;
|
|
||||||
EXECUTE stmt;
|
|
||||||
|
|
||||||
SET @s = (SELECT IF(
|
|
||||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_schema = DATABASE()
|
|
||||||
AND table_name = 'Monitors'
|
|
||||||
AND column_name = 'ManufacturerId'
|
|
||||||
) > 0,
|
|
||||||
"SELECT 'FOREIGN KEY for ManufacturerId already exists in Monitors'",
|
|
||||||
"ALTER TABLE `Monitors` ADD FOREIGN KEY (`ManufacturerId`) REFERENCES `Manufacturers` (Id)"
|
|
||||||
));
|
|
||||||
|
|
||||||
PREPARE stmt FROM @s;
|
|
||||||
EXECUTE stmt;
|
|
||||||
|
|
||||||
SET @s = (SELECT IF(
|
|
||||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
|
||||||
AND table_name = 'Monitors'
|
|
||||||
AND column_name = 'ModelId'
|
|
||||||
) > 0,
|
|
||||||
"SELECT 'Column ModelId already exists in Monitors'",
|
|
||||||
"ALTER TABLE `Monitors` ADD `ModelId` int(10) unsigned AFTER `ManufacturerId`"
|
|
||||||
));
|
|
||||||
|
|
||||||
PREPARE stmt FROM @s;
|
|
||||||
EXECUTE stmt;
|
|
||||||
|
|
||||||
SET @s = (SELECT IF(
|
|
||||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_schema = DATABASE()
|
|
||||||
AND table_name = 'Monitors'
|
|
||||||
AND column_name = 'ModelId'
|
|
||||||
) > 0,
|
|
||||||
"SELECT 'FOREIGN KEY for ModelId already exists in Monitors'",
|
|
||||||
"ALTER TABLE `Monitors` ADD FOREIGN KEY (`ModelId`) REFERENCES `Models` (Id)"
|
|
||||||
));
|
|
||||||
|
|
||||||
PREPARE stmt FROM @s;
|
|
||||||
EXECUTE stmt;
|
|
Loading…
Reference in New Issue