veylant/migrations/000008_rate_limits.up.sql
2026-02-23 13:35:04 +01:00

13 lines
696 B
SQL

-- Rate limiting configuration per tenant.
-- Rows are optional — absent tenant_id falls back to application defaults.
CREATE TABLE IF NOT EXISTS rate_limit_configs (
tenant_id TEXT PRIMARY KEY,
requests_per_min INT NOT NULL DEFAULT 1000, -- tenant-wide RPM
burst_size INT NOT NULL DEFAULT 200, -- burst capacity
user_rpm INT NOT NULL DEFAULT 100, -- per-user RPM within tenant
user_burst INT NOT NULL DEFAULT 20, -- per-user burst
is_enabled BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);