-- ----------------------------
-- 达梦数据库 - 系统字典表建表语句
-- Source Schema: employmentsitedb_dev
-- Date: 2026-06-03
-- ----------------------------

-- ----------------------------
-- Table structure for dictionary
-- ----------------------------
DROP TABLE IF EXISTS DICTIONARY;
CREATE TABLE DICTIONARY
(
    DictionaryCode VARCHAR(50) NOT NULL,
    Name           VARCHAR(500),
    OrderNo        INT         NOT NULL,
    RecordStatus   INT         NOT NULL,
    DictType       INT         DEFAULT 0,
    PRIMARY KEY (DictionaryCode)
);

-- ----------------------------
-- Table structure for dictionary_item
-- ----------------------------
DROP TABLE IF EXISTS DICTIONARY_ITEM;
CREATE TABLE DICTIONARY_ITEM
(
    DictionaryItemID VARCHAR(50) NOT NULL,
    Code             VARCHAR(50) NOT NULL,
    DictionaryCode   VARCHAR(50),
    Value            INT,
    Name             VARCHAR(100),
    OrderNo          INT         NOT NULL,
    RecordStatus     INT,
    IsEditable       TINYINT,
    ParentItemID     VARCHAR(50),
    PRIMARY KEY (DictionaryItemID)
);

-- ----------------------------
-- 树形字典支持 - 修改已有表结构（如需升级已有数据库）
-- ----------------------------
ALTER TABLE DICTIONARY ADD DictType INT DEFAULT 0;
ALTER TABLE DICTIONARY_ITEM ADD ParentItemID VARCHAR(50);

