DROP TABLE IF EXISTS sys_setting;

CREATE TABLE sys_setting (
    id BIGSERIAL PRIMARY KEY,
    catalog VARCHAR(200) NOT NULL,
    type VARCHAR(200) NOT NULL,
    name VARCHAR(200) NOT NULL,
    value INTEGER NOT NULL,
    strvalue VARCHAR(500),
    sort INTEGER DEFAULT 0,
    version INTEGER NOT NULL DEFAULT 1,
    create_time TIMESTAMP,
    update_time TIMESTAMP,
    remark VARCHAR(500) DEFAULT '',
    create_by VARCHAR(64),
    update_by VARCHAR(64),
    CONSTRAINT uk_catalog_type_name UNIQUE (catalog, type, name)
);

CREATE INDEX idx_sys_setting_catalog_type ON sys_setting (catalog, type);
CREATE INDEX idx_sys_setting_sort ON sys_setting (sort);

COMMENT ON TABLE sys_setting IS '系统枚举类';
COMMENT ON COLUMN sys_setting.id IS 'ID';
COMMENT ON COLUMN sys_setting.catalog IS '模块';
COMMENT ON COLUMN sys_setting.type IS '类型';
COMMENT ON COLUMN sys_setting.name IS '名称';
COMMENT ON COLUMN sys_setting.value IS '值';
COMMENT ON COLUMN sys_setting.strvalue IS '字符串值';
COMMENT ON COLUMN sys_setting.sort IS '排序';
COMMENT ON COLUMN sys_setting.version IS '版本';
COMMENT ON COLUMN sys_setting.create_time IS '创建时间';
COMMENT ON COLUMN sys_setting.update_time IS '更新时间';
COMMENT ON COLUMN sys_setting.remark IS '备注';
COMMENT ON COLUMN sys_setting.create_by IS '创建者';
COMMENT ON COLUMN sys_setting.update_by IS '更新者';
