mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 21:32:40 +00:00
a54e16b7ea
This PR adds a `usages` table to the LLM database. We'll use this to track usage for rate-limiting purposes. Release Notes: - N/A
15 lines
663 B
SQL
15 lines
663 B
SQL
create table if not exists usages (
|
|
id serial primary key,
|
|
user_id integer not null,
|
|
model_id integer not null references models (id) on delete cascade,
|
|
requests_this_minute integer not null default 0,
|
|
tokens_this_minute bigint not null default 0,
|
|
requests_this_day integer not null default 0,
|
|
tokens_this_day bigint not null default 0,
|
|
requests_this_month integer not null default 0,
|
|
tokens_this_month bigint not null default 0
|
|
);
|
|
|
|
create index ix_usages_on_user_id on usages (user_id);
|
|
create index ix_usages_on_model_id on usages (model_id);
|
|
create unique index uix_usages_on_user_id_model_id on usages (user_id, model_id);
|