DROP TABLE IF EXISTS sys_enum;

CREATE TABLE sys_enum (
    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_enum_catalog_type ON sys_enum (catalog, type);
CREATE INDEX idx_sys_enum_sort ON sys_enum (sort);

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