-- 药物禁配标准主表 + 配伍子表（无 publish 字段）
CREATE TABLE IF NOT EXISTS `biz_drug_incompatibility_standard` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `main_drug_name` varchar(64) NOT NULL COMMENT '主药名称1～20字',
  `compat_result` varchar(64) DEFAULT NULL COMMENT '配伍结果选填≤50字',
  `kb_sync_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0未同步1已同步',
  `kb_doc_id` varchar(128) DEFAULT NULL COMMENT '知识库文档ID',
  `create_by` varchar(64) DEFAULT '' COMMENT '创建者',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) DEFAULT '' COMMENT '更新者',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`),
  KEY `idx_create_time` (`create_time`),
  KEY `idx_kb` (`kb_sync_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='药物禁配标准主表';

CREATE TABLE IF NOT EXISTS `biz_drug_incompatibility_companion` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `standard_id` bigint(20) NOT NULL COMMENT '标准主表ID',
  `companion_drug_name` varchar(64) NOT NULL COMMENT '配伍药物名称1～20字',
  `sort_order` int(11) NOT NULL DEFAULT '0' COMMENT '展示顺序',
  PRIMARY KEY (`id`),
  KEY `idx_standard_id` (`standard_id`),
  UNIQUE KEY `uk_std_companion` (`standard_id`,`companion_drug_name`),
  CONSTRAINT `fk_dic_standard` FOREIGN KEY (`standard_id`) REFERENCES `biz_drug_incompatibility_standard` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='药物禁配标准配伍子表';
