create table if not exists patrol_template
(
    id          serial       not null
        constraint patrol_template_pk
            primary key,
    name        varchar(128) not null,
    describe    varchar(1024),
    create_user_id integer      not null
);

create unique index if not exists patrol_template_id_uindex
    on patrol_template (id);




create table if not exists patrol_template_check_items
(
    id             serial  not null
        constraint patrol_template_check_items_pk
            primary key,
    template_id    integer not null
        constraint patrol_template_check_items_patrol_template_id_fk
            references patrol_template,
    check_items_id integer not null
        constraint patrol_template_check_items_check_items_id_fk
            references check_items
);

create unique index if not exists patrol_template_check_items_id_uindex
    on patrol_template_check_items (id);
