Changeset 0.22.4 (#146)
This commit is contained in:
33
server/database/migrations/015_v0224_health_enhance.sql
Normal file
33
server/database/migrations/015_v0224_health_enhance.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- v0.22.4: Rate limit tracking, tool health, project files.
|
||||
|
||||
-- ── Rate limit column on provider_health ────
|
||||
ALTER TABLE provider_health ADD COLUMN IF NOT EXISTS rate_limit_count INT NOT NULL DEFAULT 0;
|
||||
|
||||
-- ── Tool Health ─────────────────────────────
|
||||
-- Lightweight health tracking for built-in tools (web_search, url_fetch, etc.).
|
||||
-- One row per tool per hourly window, similar to provider_health.
|
||||
CREATE TABLE IF NOT EXISTS tool_health (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
tool_name TEXT NOT NULL, -- web_search, url_fetch, etc.
|
||||
window_start TIMESTAMPTZ NOT NULL, -- hourly bucket floor
|
||||
request_count INT NOT NULL DEFAULT 0,
|
||||
error_count INT NOT NULL DEFAULT 0,
|
||||
total_latency_ms BIGINT NOT NULL DEFAULT 0,
|
||||
max_latency_ms INT NOT NULL DEFAULT 0,
|
||||
last_error TEXT,
|
||||
last_error_at TIMESTAMPTZ,
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
|
||||
UNIQUE (tool_name, window_start)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_tool_health_window
|
||||
ON tool_health (tool_name, window_start DESC);
|
||||
|
||||
-- ── Project Files ───────────────────────────
|
||||
-- Extends attachments to support project-scoped uploads.
|
||||
-- When project_id is set, the file belongs to the project (not a message).
|
||||
ALTER TABLE attachments ADD COLUMN IF NOT EXISTS project_id UUID REFERENCES projects(id) ON DELETE CASCADE;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_attachments_project
|
||||
ON attachments (project_id) WHERE project_id IS NOT NULL;
|
||||
@@ -0,0 +1,22 @@
|
||||
-- v0.22.4: Rate limit tracking, tool health, project files (SQLite).
|
||||
|
||||
-- Rate limit column (SQLite requires full rebuild or default — use default).
|
||||
ALTER TABLE provider_health ADD COLUMN rate_limit_count INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
-- Tool Health
|
||||
CREATE TABLE IF NOT EXISTS tool_health (
|
||||
id TEXT PRIMARY KEY,
|
||||
tool_name TEXT NOT NULL,
|
||||
window_start TEXT NOT NULL,
|
||||
request_count INTEGER NOT NULL DEFAULT 0,
|
||||
error_count INTEGER NOT NULL DEFAULT 0,
|
||||
total_latency_ms INTEGER NOT NULL DEFAULT 0,
|
||||
max_latency_ms INTEGER NOT NULL DEFAULT 0,
|
||||
last_error TEXT,
|
||||
last_error_at TEXT,
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
UNIQUE (tool_name, window_start)
|
||||
);
|
||||
|
||||
-- Project Files
|
||||
ALTER TABLE attachments ADD COLUMN project_id TEXT REFERENCES projects(id) ON DELETE CASCADE;
|
||||
Reference in New Issue
Block a user