-- sql history
CREATE TABLE IF NOT EXISTS sys_sql_history (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    file TEXT NOT NULL,
    updated_at TIMESTAMP DEFAULT (DATETIME(CURRENT_TIMESTAMP, 'localtime'))
);

-- system
CREATE TABLE IF NOT EXISTS sys_system (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    code TEXT NOT NULL,
    val TEXT NOT NULL,
    updated_at TIMESTAMP DEFAULT (DATETIME(CURRENT_TIMESTAMP, 'localtime'))
);
insert into sys_system(code, val) values ('software_version', '1.0.0');
insert into sys_system(code, val) values ('firmware_version', '1.0.0');
insert into sys_system(code, val) values ('algorithm_version', '1.0.0');
insert into sys_system(code, val) values ('model_version', '1.0.0');

-- user
CREATE TABLE IF NOT EXISTS sys_user (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    username TEXT NOT NULL,
    password TEXT NOT NULL,
    created_at TIMESTAMP DEFAULT (DATETIME(CURRENT_TIMESTAMP, 'localtime'))
);
insert into sys_user(username, password) values ('admin', 'winner!');

-- task
CREATE TABLE IF NOT EXISTS sys_task (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    creator TEXT NULL,
    steps TEXT NOT NULL,
    result TEXT NULL,
    state INTEGER default 0,
    created_at TIMESTAMP DEFAULT (DATETIME(CURRENT_TIMESTAMP, 'localtime'))
);
