20241010151249_create_billing_events.sql

 1create table billing_events (
 2    id serial primary key,
 3    idempotency_key uuid not null default gen_random_uuid(),
 4    user_id integer not null,
 5    model_id integer not null references models (id) on delete cascade,
 6    input_tokens bigint not null default 0,
 7    input_cache_creation_tokens bigint not null default 0,
 8    input_cache_read_tokens bigint not null default 0,
 9    output_tokens bigint not null default 0
10);
11
12create index uix_billing_events_on_user_id_model_id on billing_events (user_id, model_id);