PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
DROP TABLE IF EXISTS tbl_data_sensor;
DROP INDEX IF EXISTS idx_sensor_device;
DROP TABLE IF EXISTS tbl_data_exp;
DROP INDEX IF EXISTS idx_exp_device;
CREATE TABLE IF NOT EXISTS tbl_data_sensor(id_device varchar(36), timestamp text, temperature real, humidity real, co2 real, counter_1 real, counter_2 real, alarms real, valve_status real); 
CREATE INDEX IF NOT EXISTS idx_sensor_device ON tbl_data_sensor(id_device);
CREATE TABLE IF NOT EXISTS tbl_data_exp(id_device varchar(36), timestamp text, temperature_1 real, temperature_2 real, input_1 real, input_2 real, input_3 real, input_4 real, input_5 real, input_6 real, input_7 real, input_8 real); 
CREATE INDEX IF NOT EXISTS idx_exp_device ON tbl_data_exp(id_device);
CREATE TABLE IF NOT EXISTS tbl_data_rfg(id_device varchar(36), timestamp text, conc_sens1 real, conc_sens2 real, conc_sens3 real, ths_exc_sens1 real, ths_exc_sens2 real, ths_exc_sens3 real, status_sens1 real, status_sens2 real, status_sens3 real, status_rele real); 
CREATE INDEX IF NOT EXISTS idx_rfg_device ON tbl_data_rfg(id_device);
COMMIT;
