Try to fix sql schema 278 (#9715)

This commit is contained in:
Tony Murray 2019-01-22 17:05:54 -06:00 committed by GitHub
parent d64f3acb15
commit 8176470795
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -1 +1 @@
INSERT INTO `config` (`config_name`, `config_value`, `config_default`, `config_descr`, `config_group`, `config_group_order`, `config_sub_group`, `config_sub_group_order`, `config_hidden`, `config_disabled`) VALUES('webui.dynamic_graphs', 'false', 'false', 'Enable dynamic graphs', 'webui', 0, 'graph', 0, 0, '0');
INSERT INTO `config` (`config_name`, `config_value`, `config_default`, `config_descr`, `config_group`, `config_group_order`, `config_sub_group`, `config_sub_group_order`, `config_hidden`, `config_disabled`) VALUES('webui.dynamic_graphs', 'false', 'false', 'Enable dynamic graphs', 'webui', 0, 'graph', 0, '0', '0');

View File

@ -109,7 +109,11 @@ alter table widgets modify widget_id int unsigned auto_increment;
alter table wireless_sensors modify sensor_id int unsigned auto_increment, modify access_point_id int unsigned null;
LOCK TABLES sensors WRITE, sensors_to_state_indexes WRITE, state_indexes WRITE;
alter table sensors_to_state_indexes drop foreign key sensors_to_state_indexes_ibfk_2, drop foreign key sensors_to_state_indexes_sensor_id_foreign;
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;
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;