-- 创建所有表
CREATE TABLE IF NOT EXISTS air_conditioner (
    id VARCHAR(128) PRIMARY KEY, 
    "on" BOOLEAN NOT NULL, 
    temperature REAL NOT NULL, 
    burnt BOOLEAN NOT NULL, 
    frozen BOOLEAN NOT NULL
);

CREATE TABLE IF NOT EXISTS air_conditioner_log (
    log_id INTEGER PRIMARY KEY AUTOINCREMENT,
    log_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    id VARCHAR(128), 
    "on" BOOLEAN NOT NULL, 
    temperature REAL NOT NULL, 
    burnt BOOLEAN NOT NULL, 
    frozen BOOLEAN NOT NULL,
    FOREIGN KEY (id) REFERENCES air_conditioner(id)
);

CREATE TABLE IF NOT EXISTS air_conditioner_crash_log (
    id VARCHAR(128) NOT NULL,
    crash_type INT NOT NULL,
    timestamp DATETIME NOT NULL,
    FOREIGN KEY (id) REFERENCES air_conditioner(id)
);