CREATE TABLE IF NOT EXISTS user (
userID int(11) NOT NULL AUTO_INCREMENT,
datetime TIMESTAMP NOT NULL DEFAULT current_timestamp() COMMENT "紀錄時間",
firstname varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT "姓氏",
lastname varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT "名字",
mail varchar(256) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT "電子郵件",
phone varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT "連絡電話",
username varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT "使用者名稱",
password varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT "密碼",
status int(11) NOT NULL COMMENT "0:admin;1:superuser;2:enduser;8:new;9:disable",
PRIMARY KEY(userID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO user (firstname, lastname, mail, phone, username, password, status) VALUES
("firstname", "lastname", "aaa@gmail.com", "0987654321", "user", "123456", 1);

CREATE TABLE IF NOT EXISTS dry_tank_actuator(
sn int(11) NOT NULL AUTO_INCREMENT COMMENT '流水號',
datetime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '紀錄時間',
tank_num varchar(3) NOT NULL COMMENT '乾燥槽編號(D1~D12)',
vacuum tinyint(1) NOT NULL DEFAULT '0' COMMENT '真空吸料機',
threewayvalve_input tinyint(1) NOT NULL DEFAULT '0' COMMENT '吸料機三通閥',
solenoid_disinfect tinyint(1) NOT NULL DEFAULT '0' COMMENT '消毒閥',
motor int(11) NOT NULL DEFAULT '0' COMMENT '馬達',
solenoid_outer_water tinyint(1) NOT NULL DEFAULT '0' COMMENT '桶外進水電磁閥',
solenoid_water_out tinyint(1) NOT NULL DEFAULT '0' COMMENT '廢水排水電磁閥',
heater1 tinyint(1) NOT NULL DEFAULT '0' COMMENT '加熱管 1',
heater2 tinyint(1) NOT NULL DEFAULT '0' COMMENT '加熱管 2',
temp_enable tinyint(1) NOT NULL DEFAULT '0' COMMENT '溫控開關',
temp float NOT NULL DEFAULT '0' COMMENT '設定溫度',
diskvalve tinyint(1) NOT NULL DEFAULT '0' COMMENT '蝴蝶閥',
switch_magnetic tinyint(1) NOT NULL DEFAULT '0' COMMENT '電磁開關',
switch_emergency tinyint(1) NOT NULL DEFAULT '0' COMMENT '緊急開關',
camera tinyint(1) NOT NULL DEFAULT '0' COMMENT '攝影機',
light_warning tinyint(1) NOT NULL DEFAULT '0' COMMENT '警示燈',
PRIMARY KEY (sn)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS dry_tank_SHT11(
sn int(11) NOT NULL AUTO_INCREMENT COMMENT '流水號',
datetime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '紀錄時間',
tank_num varchar(3) NOT NULL COMMENT '乾燥槽編號(D1~D12)',
SHT11_Temp varchar(16) NOT NULL DEFAULT '0' COMMENT 'SHT11 溫度 (單位℃)',
SHT11_Humidity varchar(16) NOT NULL DEFAULT '0' COMMENT 'SHT11 濕度 (單位%)',
PRIMARY KEY (sn)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;