-- 1. 为维修单主表添加富文本内容字段（维修描述）
ALTER TABLE `dm_repair_order` 
ADD COLUMN `rich_text_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '富文本内容（维修描述）' AFTER `remark`;

-- 2. 为维修单明细表添加富文本内容字段（放在fault_name后面）
ALTER TABLE `dm_repair_order_entry` 
ADD COLUMN `rich_text_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '富文本内容' AFTER `fault_name`;

-- 2. 创建维修单附件表
CREATE TABLE `dm_repair_order_attachment` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `repair_order_id` bigint NOT NULL COMMENT '维修单ID',
  `entry_id` bigint DEFAULT NULL COMMENT '明细ID（可为空，表示主单附件）',
  `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '文件名称',
  `file_path` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '文件路径',
  `file_size` bigint NOT NULL COMMENT '文件大小（字节）',
  `file_type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '文件类型',
  `create_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '创建人',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `update_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '状态（0正常 1删除）',
  `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_repair_order_id` (`repair_order_id`) USING BTREE,
  KEY `idx_entry_id` (`entry_id`) USING BTREE,
  KEY `idx_status` (`status`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='维修单附件表';
