create table if not exists billing.receipt ( id bigserial primary key, reading_id bigint not null unique references billing.reading (id) on delete cascade, created_at timestamptz not null default now(), key_digest bytea not null check (octet_length(key_digest) = 32), data jsonb not null );