create table if not exists maintenance_plan ( id serial not null constraint maintenance_plan_pk primary key, mission_name varchar(1024) not null, remark varchar(1024), reason varchar(1024), plan_finish_time timestamp with time zone, actual_finish_time timestamp with time zone, type varchar(32) not null, state varchar(32) not null ); comment on table maintenance_plan is '维护计划'; comment on column maintenance_plan.mission_name is '任务名称'; comment on column maintenance_plan.remark is '备注'; comment on column maintenance_plan.reason is '操作/故障原因'; comment on column maintenance_plan.plan_finish_time is '计划完成时间'; comment on column maintenance_plan.actual_finish_time is '实际完成时间 '; comment on column maintenance_plan.type is '分类 period 周期 / temp 临时'; comment on column maintenance_plan.state is '完成状态 unfinished 未完成 / underway 进行中 / completed 已完成 / suspend 挂起暂停 / inspected 已检查'; create unique index if not exists maintenance_plan_id_uindex on maintenance_plan (id); create table if not exists maintenance_plan_execute_user ( id serial not null constraint maintenance_plan_execute_user_pk primary key, maintenance_plan_id integer not null constraint maintenance_plan_execute_user_maintenance_plan_id_fk references maintenance_plan, pep_user_id integer not null ); comment on table maintenance_plan_execute_user is '维护计划执行人'; comment on column maintenance_plan_execute_user.pep_user_id is '项企用户id'; create unique index if not exists maintenance_plan_execute_user_id_uindex on maintenance_plan_execute_user (id); create table if not exists maintenance_record ( id serial not null constraint maintenance_record_pk primary key, sketch varchar(512) not null, occurrence_time timestamp with time zone, solving_time timestamp with time zone, interrupt_duration integer, type varchar(32), record varchar(1024) ); comment on table maintenance_record is '运维服务记录'; comment on column maintenance_record.sketch is '简述'; comment on column maintenance_record.occurrence_time is '发生时间'; comment on column maintenance_record.solving_time is '解决时间'; comment on column maintenance_record.interrupt_duration is '中断时长 / 秒'; comment on column maintenance_record.type is '故障类型'; comment on column maintenance_record.record is '故障记录'; create unique index if not exists maintenance_record_id_uindex on maintenance_record (id); create table if not exists maintenance_record_execute_user ( id serial not null constraint maintenance_record_execute_user_pk primary key, maintenance_record_id integer not null constraint maintenance_record_execute_user_maintenance_record_id_fk references maintenance_record, pep_user_id integer not null ); comment on table maintenance_record_execute_user is '运维服务记录解决者'; create unique index if not exists maintenance_record_execute_user_id_uindex on maintenance_record_execute_user (id);