create schema if not exists chat; create table if not exists chat.check_session ( id uuid primary key default gen_random_uuid(), reading_id bigint not null references billing.reading (id) on delete cascade, round integer not null default 1 check (round between 1 and 10), challenge integer check (challenge between 0 and 2), data text[], complete boolean not null default false ); create index if not exists check_session_reading_idx on chat.check_session (reading_id);