-- 表：bse_mtrl_grade_ext
CREATE TABLE IF NOT EXISTS bse_mtrl_grade_ext (
    id              BIGINT PRIMARY KEY,
    CMP_CD          VARCHAR(64)    NOT NULL,
    CMP_NM          VARCHAR(128),
    MTRL_CD         VARCHAR(128)   NOT NULL,
    MTRL_NM         VARCHAR(255),
    ZH_BRAND        VARCHAR(255),
    EN_BRAND        VARCHAR(255),
    SPC_MDL         VARCHAR(255),
    LINE_TP         VARCHAR(64),
    PKG             VARCHAR(255),
    company_id      BIGINT,
    company_name    VARCHAR(128),
    dept_id         BIGINT,
    dept_name       VARCHAR(128),
    post_id         BIGINT,
    tenant_id       BIGINT DEFAULT 1,
    creator_name    VARCHAR(64),
    updater_name    VARCHAR(64),
    creator         VARCHAR(64),
    create_time     TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updater         VARCHAR(64),
    update_time     TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
    deleted         BIT DEFAULT 0 NOT NULL
);

-- 索引
CREATE INDEX IF NOT EXISTS idx_bse_mtrl_grade_ext_mtrl_cd ON bse_mtrl_grade_ext (MTRL_CD);
CREATE INDEX IF NOT EXISTS idx_bse_mtrl_grade_ext_cmp_cd ON bse_mtrl_grade_ext (CMP_CD);

-- 字段注释（可选）
COMMENT ON TABLE bse_mtrl_grade_ext IS '物料牌号扩展';
COMMENT ON COLUMN bse_mtrl_grade_ext.CMP_CD IS '公司编码';
COMMENT ON COLUMN bse_mtrl_grade_ext.CMP_NM IS '公司名称';
COMMENT ON COLUMN bse_mtrl_grade_ext.MTRL_CD IS '物料编码';
COMMENT ON COLUMN bse_mtrl_grade_ext.MTRL_NM IS '物料名称';
COMMENT ON COLUMN bse_mtrl_grade_ext.ZH_BRAND IS '中文牌号';
COMMENT ON COLUMN bse_mtrl_grade_ext.EN_BRAND IS '英文牌号';
COMMENT ON COLUMN bse_mtrl_grade_ext.SPC_MDL IS '规格型号';
COMMENT ON COLUMN bse_mtrl_grade_ext.LINE_TP IS '线别（material_line_type 字典）';
COMMENT ON COLUMN bse_mtrl_grade_ext.PKG IS '包装';