-- KBX v14 API command idempotency receipt.
-- This is infrastructure state, not a domain aggregate.
create schema if not exists kbx;

create table if not exists kbx.command_receipts (
    operation_id varchar(150) not null,
    idempotency_key varchar(200) not null,
    response_json jsonb not null,
    created_at timestamptz not null default now(),
    primary key(operation_id, idempotency_key)
);

create index if not exists ix_command_receipts_created_at
    on kbx.command_receipts(created_at);
