CREATE TABLE IF NOT EXISTS agent_hook_registration ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), session_id UUID NOT NULL REFERENCES agent_session(id) ON DELETE CASCADE, hook_type TEXT NOT NULL, handler_name TEXT NOT NULL, config_json TEXT, priority INTEGER NOT NULL DEFAULT 0, enabled BOOLEAN NOT NULL DEFAULT true, created_at TIMESTAMPTZ NOT NULL DEFAULT now() ); CREATE INDEX IF NOT EXISTS idx_agent_hook_session ON agent_hook_registration(session_id, hook_type);