# test
CREATE TABLE IF NOT EXISTS `test` (
    `id`   INT AUTO_INCREMENT PRIMARY KEY,
    `name` VARCHAR(12) NOT NULL,
    `time` DATETIME DEFAULT CURRENT_TIMESTAMP
);

# device
CREATE TABLE IF NOT EXISTS `device` (
    `id`           VARCHAR(32) PRIMARY KEY,     -- 板卡SN号为device-id，最大长度不确定
    `addr`         VARCHAR(128) NOT NULL,
    `first`        DATETIME          DEFAULT CURRENT_TIMESTAMP,
    `last`         DATETIME          DEFAULT CURRENT_TIMESTAMP,
    `wine1`        SMALLINT UNSIGNED,
    `remain1`      SMALLINT UNSIGNED DEFAULT 0, -- 单位：ml, max=65535ml=65.535L
    `wine2`        SMALLINT UNSIGNED,
    `remain2`      SMALLINT UNSIGNED DEFAULT 0,
    `wine3`        SMALLINT UNSIGNED,
    `remain3`      SMALLINT UNSIGNED DEFAULT 0,
    `wine4`        SMALLINT UNSIGNED,
    `remain4`      SMALLINT UNSIGNED DEFAULT 0,
    `manager`      VARCHAR(16),
    `mark`         VARCHAR(256),
    `order`        INT UNSIGNED      DEFAULT 0, -- max=42,9496,7295
    `income`       DOUBLE            DEFAULT 0
);

# wine
CREATE TABLE IF NOT EXISTS `wine` (
    `id`       SMALLINT UNSIGNED PRIMARY KEY,
    `name`     VARCHAR(16)  NOT NULL,
    `price`    SMALLINT UNSIGNED DEFAULT 9999, -- 单位为：分
    `density`  DOUBLE            DEFAULT 1,    -- 单位：g/ml
    `picture`  VARCHAR(128) NOT NULL,
    `time`     DATETIME          DEFAULT CURRENT_TIMESTAMP,
    `describe` VARCHAR(256),
    `order`    INT UNSIGNED      DEFAULT 0,
    `income`   DOUBLE            DEFAULT 0
);
# data
10100,开发用酒-1,2888,http://localhost:3080/static/images/wine/10100.png,2023-09-22 11:42:53,kai-fa-yong-jiu-1,0,0
10101,开发用酒-2,2689,http://localhost:3080/static/images/wine/10101.png,2023-09-22 11:42:53,kai-fa-yong-jiu-2,0,0
10103,开发用酒-3,2566,http://localhost:3080/static/images/wine/10103.png,2023-09-22 11:42:53,kai-fa-yong-jiu-3,0,0
10105,开发用酒-4,2199,http://localhost:3080/static/images/wine/10105.png,2023-09-22 11:42:53,kai-fa-yong-jiu-4,0,0


# manager
CREATE TABLE IF NOT EXISTS `manager` (
    `id`           VARCHAR(16) PRIMARY KEY,
    `super`        BOOL         DEFAULT FALSE,
    `first`        DATETIME     DEFAULT CURRENT_TIMESTAMP,
    `last`         DATETIME     DEFAULT CURRENT_TIMESTAMP,
    `name`         VARCHAR(16)  NOT NULL,
    `account`      VARCHAR(32)  NOT NULL,
    `password`     VARCHAR(512) NOT NULL,
    `order`        INT UNSIGNED DEFAULT 0,
    `income`       DOUBLE       DEFAULT 0
);

# advertise
CREATE TABLE IF NOT EXISTS `advertise` (
    `id`       INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `order`    TINYINT UNSIGNED NOT NULL,
    `time`     DATETIME          DEFAULT CURRENT_TIMESTAMP,
    `type`     BOOL              DEFAULT TRUE,
    `src`      VARCHAR(128)     NOT NULL,
    `duration` SMALLINT UNSIGNED DEFAULT 3000
);

# params
CREATE TABLE IF NOT EXISTS `params` (
    `id`  INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `key` VARCHAR(32) NOT NULL,
    `value`  INT UNSIGNED DEFAULT 0
);