create table if not exists report_spot_check ( id serial not null constraint report_spot_check_pk primary key, report_id integer not null constraint report_spot_check_report_id_fk references report, spot_date date not null, prepare_id integer not null constraint report_spot_check_report_spot_check_preview_id_fk references report_spot_check_preview ); create unique index if not exists report_spot_check_id_uindex on report_spot_check (id);