Files
goclaw/migrations/000054_agent_hooks_name.down.sql
viettranx ee328d4266 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
2026-04-16 14:17:48 +07:00

18 lines
739 B
SQL

-- 000054 down — Reverse rename, re-add agent_id, drop junction + name.
ALTER TABLE hooks RENAME TO agent_hooks;
ALTER TABLE hook_agents RENAME TO agent_hook_agents;
-- Re-add deprecated column (nullable, no data to restore)
ALTER TABLE agent_hooks ADD COLUMN IF NOT EXISTS agent_id UUID REFERENCES agents(id) ON DELETE CASCADE;
-- Restore original indexes
DROP INDEX IF EXISTS idx_hooks_lookup;
CREATE INDEX idx_hooks_lookup ON agent_hooks (tenant_id, agent_id, event) WHERE enabled = TRUE;
DROP INDEX IF EXISTS idx_hook_agents_agent;
CREATE INDEX idx_hook_agents_agent ON agent_hook_agents (agent_id);
-- Drop junction table + name column
DROP TABLE IF EXISTS agent_hook_agents;
ALTER TABLE agent_hooks DROP COLUMN IF EXISTS name;