Add provider rate limit registry
This commit is contained in:
1 parent
9e44cbb31b
commit
d6e797e2b9
16 files changed
+525
-38
No files matched your search
@@ -0,0 +1,21 @@
|
||||
export const providerRateLimitObservationSchema = `
|
||||
create table if not exists provider_rate_limit_observations (
|
||||
id text primary key,
|
||||
org_id text not null references organizations(id) on delete cascade,
|
||||
provider_id text not null references providers(id) on delete cascade,
|
||||
provider_key text not null,
|
||||
model text,
|
||||
request_limit integer,
|
||||
remaining_requests integer,
|
||||
reset_at text,
|
||||
retry_after_ms integer,
|
||||
raw_state_json text not null,
|
||||
observed_at text not null
|
||||
);
|
||||
|
||||
create index if not exists idx_provider_rate_limit_observations_org_provider
|
||||
on provider_rate_limit_observations(org_id, provider_id, observed_at desc);
|
||||
|
||||
insert into schema_migrations(version, name, applied_at)
|
||||
values (22, 'provider_rate_limit_observations', datetime('now'));
|
||||
`;
|
||||
@@ -20,6 +20,7 @@ import { sdlcControlsSchema } from "./migrations/018-sdlc-controls";
|
||||
import { auditReplaySchema } from "./migrations/019-audit-replay";
|
||||
import { rollbackSnapshotsSchema } from "./migrations/020-rollback-snapshots";
|
||||
import { providerAuthBrokerSchema } from "./migrations/021-provider-auth-broker";
|
||||
import { providerRateLimitObservationSchema } from "./migrations/022-provider-rate-limit-observations";
|
||||
|
||||
interface Migration {
|
||||
version: number;
|
||||
@@ -49,6 +50,7 @@ const MIGRATIONS: Migration[] = [
|
||||
{ version: 19, name: "audit_replay", sql: auditReplaySchema },
|
||||
{ version: 20, name: "rollback_snapshots", sql: rollbackSnapshotsSchema },
|
||||
{ version: 21, name: "provider_auth_broker", sql: providerAuthBrokerSchema },
|
||||
{ version: 22, name: "provider_rate_limit_observations", sql: providerRateLimitObservationSchema },
|
||||
];
|
||||
|
||||
const SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1].version;
|
||||
|
||||
Reference in new issue
Block a user