mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #9761 from murrant/278-more
* add more index names to 278.sql * don't create 1000.sql migration table if it exists
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
CREATE TABLE migrations (id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, migration VARCHAR(255) NOT NULL, batch INT NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS migrations (id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, migration VARCHAR(255) NOT NULL, batch INT NOT NULL);
|
||||
INSERT INTO migrations (migration, batch) VALUES ('2018_07_03_091314_create_access_points_table', 1);
|
||||
INSERT INTO migrations (migration, batch) VALUES ('2018_07_03_091314_create_alert_device_map_table', 1);
|
||||
INSERT INTO migrations (migration, batch) VALUES ('2018_07_03_091314_create_alert_group_map_table', 1);
|
||||
|
@ -112,11 +112,14 @@ LOCK TABLES sensors WRITE, sensors_to_state_indexes WRITE, state_indexes WRITE;
|
||||
|
||||
SELECT COUNT(*) INTO @FOREIGN_KEY_sensors_to_state_indexes_ibfk_1_ON_TABLE_sensors_to_state_indexes_EXISTS FROM `information_schema`.`table_constraints` WHERE `table_name` = 'sensors_to_state_indexes' AND `constraint_name` = 'sensors_to_state_indexes_ibfk_1' AND `constraint_type` = 'FOREIGN KEY'; SET @statement1 := IF(@FOREIGN_KEY_sensors_to_state_indexes_ibfk_1_ON_TABLE_sensors_to_state_indexes_EXISTS > 0, 'ALTER TABLE sensors_to_state_indexes DROP FOREIGN KEY sensors_to_state_indexes_ibfk_1', 'SELECT "info: foreign key sensors_to_state_indexes_ibfk_1 does not exist."'); PREPARE statement1 FROM @statement1; EXECUTE statement1;
|
||||
SELECT COUNT(*) INTO @FOREIGN_KEY_sensors_to_state_indexes_ibfk_2_ON_TABLE_sensors_to_state_indexes_EXISTS FROM `information_schema`.`table_constraints` WHERE `table_name` = 'sensors_to_state_indexes' AND `constraint_name` = 'sensors_to_state_indexes_ibfk_2' AND `constraint_type` = 'FOREIGN KEY'; SET @statement2 := IF(@FOREIGN_KEY_sensors_to_state_indexes_ibfk_2_ON_TABLE_sensors_to_state_indexes_EXISTS > 0, 'ALTER TABLE sensors_to_state_indexes DROP FOREIGN KEY sensors_to_state_indexes_ibfk_2', 'SELECT "info: foreign key sensors_to_state_indexes_ibfk_2 does not exist."'); PREPARE statement2 FROM @statement2; EXECUTE statement2;
|
||||
alter table sensors_to_state_indexes drop foreign key sensors_to_state_indexes_sensor_id_foreign;
|
||||
SELECT COUNT(*) INTO @FOREIGN_KEY_sensors_to_state_indexes_ibfk_3_ON_TABLE_sensors_to_state_indexes_EXISTS FROM `information_schema`.`table_constraints` WHERE `table_name` = 'sensors_to_state_indexes' AND `constraint_name` = 'sensors_to_state_indexes_ibfk_3' AND `constraint_type` = 'FOREIGN KEY'; SET @statement3 := IF(@FOREIGN_KEY_sensors_to_state_indexes_ibfk_3_ON_TABLE_sensors_to_state_indexes_EXISTS > 0, 'ALTER TABLE sensors_to_state_indexes DROP FOREIGN KEY sensors_to_state_indexes_ibfk_3', 'SELECT "info: foreign key sensors_to_state_indexes_ibfk_3 does not exist."'); PREPARE statement3 FROM @statement3; EXECUTE statement3;
|
||||
SELECT COUNT(*) INTO @FOREIGN_KEY_sensors_to_state_indexes_ibfk_4_ON_TABLE_sensors_to_state_indexes_EXISTS FROM `information_schema`.`table_constraints` WHERE `table_name` = 'sensors_to_state_indexes' AND `constraint_name` = 'sensors_to_state_indexes_ibfk_4' AND `constraint_type` = 'FOREIGN KEY'; SET @statement4 := IF(@FOREIGN_KEY_sensors_to_state_indexes_ibfk_4_ON_TABLE_sensors_to_state_indexes_EXISTS > 0, 'ALTER TABLE sensors_to_state_indexes DROP FOREIGN KEY sensors_to_state_indexes_ibfk_4', 'SELECT "info: foreign key sensors_to_state_indexes_ibfk_4 does not exist."'); PREPARE statement4 FROM @statement4; EXECUTE statement4;
|
||||
SELECT COUNT(*) INTO @FOREIGN_KEY_sensors_to_state_indexes_ibfk_5_ON_TABLE_sensors_to_state_indexes_EXISTS FROM `information_schema`.`table_constraints` WHERE `table_name` = 'sensors_to_state_indexes' AND `constraint_name` = 'sensors_to_state_indexes_ibfk_5' AND `constraint_type` = 'FOREIGN KEY'; SET @statement5 := IF(@FOREIGN_KEY_sensors_to_state_indexes_ibfk_5_ON_TABLE_sensors_to_state_indexes_EXISTS > 0, 'ALTER TABLE sensors_to_state_indexes DROP FOREIGN KEY sensors_to_state_indexes_ibfk_5', 'SELECT "info: foreign key sensors_to_state_indexes_ibfk_5 does not exist."'); PREPARE statement5 FROM @statement5; EXECUTE statement5;
|
||||
SELECT COUNT(*) INTO @FOREIGN_KEY_sensors_to_state_indexes_sensor_id_foreign_ON_TABLE_sensors_to_state_indexes_EXISTS FROM `information_schema`.`table_constraints` WHERE `table_name` = 'sensors_to_state_indexes' AND `constraint_name` = 'sensors_to_state_indexes_sensor_id_foreign' AND `constraint_type` = 'FOREIGN KEY'; SET @statement0 := IF(@FOREIGN_KEY_sensors_to_state_indexes_sensor_id_foreign_ON_TABLE_sensors_to_state_indexes_EXISTS > 0, 'ALTER TABLE sensors_to_state_indexes DROP FOREIGN KEY sensors_to_state_indexes_sensor_id_foreign', 'SELECT "info: foreign key sensors_to_state_indexes_sensor_id_foreign does not exist."'); PREPARE statement0 FROM @statement0; EXECUTE statement0;
|
||||
|
||||
alter table sensors modify sensor_id int unsigned auto_increment;
|
||||
alter table sensors_to_state_indexes modify sensor_id int unsigned not null, modify state_index_id int unsigned not null;
|
||||
alter table state_indexes modify state_index_id int unsigned auto_increment;
|
||||
ALTER TABLE `sensors_to_state_indexes` ADD FOREIGN KEY (`state_index_id`) REFERENCES `state_indexes`(`state_index_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||
ALTER TABLE `sensors_to_state_indexes` ADD CONSTRAINT `sensors_to_state_indexes_ibfk_1` FOREIGN KEY (`state_index_id`) REFERENCES `state_indexes`(`state_index_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
|
||||
ALTER TABLE `sensors_to_state_indexes` ADD CONSTRAINT `sensors_to_state_indexes_sensor_id_foreign` FOREIGN KEY (`sensor_id`) REFERENCES `sensors` (`sensor_id`) ON DELETE CASCADE;
|
||||
UNLOCK TABLES;
|
||||
|
Reference in New Issue
Block a user