change polling code to use models (#9766)

This commit is contained in:
Tony Murray 2019-01-31 10:40:20 -06:00 committed by GitHub
parent 65e766156f
commit 431b645303
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -110,12 +110,12 @@ alter table wireless_sensors modify sensor_id int unsigned auto_increment, modif
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;
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;
SELECT COUNT(*) INTO @ibfk_1_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(@ibfk_1_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 @ibfk_2_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(@ibfk_2_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;
SELECT COUNT(*) INTO @ibfk_3_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(@ibfk_3_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 @ibfk_4_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(@ibfk_4_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 @ibfk_5_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(@ibfk_5_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 @sensor_id_foreign_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(@sensor_id_foreign_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;