# 维修记录主表, 关联设备更换记录表
create table uav_maintenance_recordrepair_record
(
    id                        int primary key auto_increment comment '主键id',
    uniId                     varchar(32)      not null comment '工单号',
    uav_id                    int              not null comment '无人机id',
    uav_sn                    varchar(32)      not null comment '飞机唯一识别码',
    uav_model                 int              not null comment '飞机型号',
    repair_date          date             not null comment '维修日期',
    repair_location      varchar(64) comment '维修地点',
    repair_type          tinyint unsigned not null comment '维修类型, enum: 0-计划性维修, 2-非计划性维修, 3-缺陷修复, 255-其他',
    support_doc               tinyint unsigned not null comment '依据文件, enum: 0-问题报告单, 1-偏离单, 255-其他',
    fault_description         varchar(255)     not null comment '故障/缺陷描述',
    repair_measures      varchar(255)     not null comment '维修措施',
    test_result               tinyint unsigned not null comment '测试结果, enum: 0-未通过, 1-已通过, 2-待检验',
    repair_person        varchar(50)      not null comment '维修负责人员',
    quality_inspector         varchar(50)      not null comment '质检人员',
    authorized_release_person varchar(50)      not null comment '授权放行人员',
    status                    tinyint  not null default 'draft' comment '工单状态, enum: 0-草稿, 1-已提交, 2-已撤销, 3-已关闭',
    create_time               datetime,
    update_time               datetime,
#     create_by                 varchar(50),
#     update_by                 varchar(50),
#     is_deleted           tinyint(1)            default 0,
    unique key uk_uni_id (uniId),
    index idx_uav_id (uav_id),
    foreign key (uav_id) references uav_basic_info (id) # todo 记得删除
) comment '维修记录主表';