-- 物料：无批次时 batch 为空串，物料编码唯一；有批次时 (code, batch) 唯一

ALTER TABLE `man_matnr`
    ADD COLUMN `batch` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '批次，空串表示无批次' AFTER `code`;

UPDATE `man_matnr` SET `batch` = '' WHERE `batch` IS NULL;

CREATE UNIQUE INDEX `uk_man_matnr_code_batch` ON `man_matnr` (`code`, `batch`);
