mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-15 16:14:43 +00:00
refactor: consolidate hooks table migration and drop deprecated agent_id column
- Consolidated PG migration 054: agent_hooks rename + junction table + deprecated column drop - Updated SQLite schema v19 with final consolidated migration - Removed obsolete schema rebuild files (v21, v23) - Updated Go store layer (pg/hooks.go, sqlitestore/hooks.go) - Updated integration tests to use new table names (hooks, hook_agents) - Updated TypeScript protocol, UI components, and i18n strings - Updated gateway methods to reflect schema changes Tables: agent_hooks → hooks, agent_hook_agents → hook_agents
This commit is contained in:
1 parent
6659ba46a8
commit
ee328d4266
49 files changed
+622
-388
No files matched your search
@@ -1570,18 +1570,14 @@ CREATE INDEX IF NOT EXISTS idx_vault_links_source
|
||||
WHERE json_extract(metadata, '$.source') IS NOT NULL;
|
||||
|
||||
-- ============================================================
|
||||
-- Table: agent_hooks (migrations 000052 + 000053)
|
||||
-- Table: hooks (renamed from agent_hooks, migration 000055)
|
||||
-- SQLite translation: JSONB→TEXT, TIMESTAMPTZ→TEXT, UUID→TEXT,
|
||||
-- BYTEA→BLOB, DATE→TEXT (ISO8601), CHECK for enums.
|
||||
-- v21 (migration 000053): handler_type adds 'script', source adds 'builtin',
|
||||
-- old (event, handler_type) uniqueness indexes dropped — scripts routinely
|
||||
-- want many small hooks per event.
|
||||
-- ============================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS agent_hooks (
|
||||
CREATE TABLE IF NOT EXISTS hooks (
|
||||
id TEXT NOT NULL PRIMARY KEY,
|
||||
tenant_id TEXT NOT NULL DEFAULT '0193a5b0-7000-7000-8000-000000000001',
|
||||
agent_id TEXT REFERENCES agents(id) ON DELETE CASCADE,
|
||||
scope TEXT NOT NULL CHECK (scope IN ('global', 'tenant', 'agent')),
|
||||
event TEXT NOT NULL,
|
||||
handler_type TEXT NOT NULL CHECK (handler_type IN ('command', 'http', 'prompt', 'script')),
|
||||
@@ -1602,16 +1598,29 @@ CREATE TABLE IF NOT EXISTS agent_hooks (
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_hooks_lookup
|
||||
ON agent_hooks (tenant_id, agent_id, event)
|
||||
ON hooks (tenant_id, event)
|
||||
WHERE enabled = 1;
|
||||
|
||||
-- ============================================================
|
||||
-- Table: hook_agents (renamed from agent_hook_agents, N:M junction)
|
||||
-- ============================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS hook_agents (
|
||||
hook_id TEXT NOT NULL REFERENCES hooks(id) ON DELETE CASCADE,
|
||||
agent_id TEXT NOT NULL REFERENCES agents(id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (hook_id, agent_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_hook_agents_agent
|
||||
ON hook_agents (agent_id);
|
||||
|
||||
-- ============================================================
|
||||
-- Table: hook_executions (append-only audit log, migration 000052)
|
||||
-- ============================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS hook_executions (
|
||||
id TEXT NOT NULL PRIMARY KEY,
|
||||
hook_id TEXT REFERENCES agent_hooks(id) ON DELETE SET NULL,
|
||||
hook_id TEXT REFERENCES hooks(id) ON DELETE SET NULL,
|
||||
session_id TEXT,
|
||||
event TEXT NOT NULL,
|
||||
input_hash TEXT,
|
||||
|
||||
Reference in new issue
Block a user