create table if not exists workorder
(
    id              serial  not null
        constraint workorder_pk
            primary key,
    story_id        integer not null,
    poms_project_id integer
        constraint workorder_project_correlation_id_fk
            references project_correlation,
    expect_time     timestamp with time zone,
    create_time     timestamp with time zone,
    complete_time   timestamp with time zone,
    state           varchar(64),
    problem_type    varchar(128),
    solution        varchar(128)
);

comment on table workorder is '工单信息 定时任务采集自项企工作流';

comment on column workorder.story_id is '项企工作流的 history_id 实例id';

comment on column workorder.poms_project_id is '运维的项目的id';

comment on column workorder.expect_time is '期望解决时间';

comment on column workorder.create_time is '创建时间';

comment on column workorder.complete_time is '解决时间';

comment on column workorder.state is '状态';

comment on column workorder.problem_type is '问题类型';

comment on column workorder.solution is '解决方案';

create unique index if not exists workorder_id_uindex
    on workorder (id);

create unique index if not exists workorder_story_id_uindex
    on workorder (story_id);

