-- ============================================================================
-- Migration: remove_directive_system.sql
-- Removes the entire directive/chain system.
-- ============================================================================

-- Drop directive tables in reverse dependency order
DROP TABLE IF EXISTS directive_approvals CASCADE;
DROP TABLE IF EXISTS directive_verifiers CASCADE;
DROP TABLE IF EXISTS directive_events CASCADE;
DROP TABLE IF EXISTS directive_evaluations CASCADE;
DROP TABLE IF EXISTS chain_steps CASCADE;
DROP TABLE IF EXISTS directive_chains CASCADE;
DROP TABLE IF EXISTS directives CASCADE;

-- Remove directive-related columns from contracts
ALTER TABLE contracts DROP COLUMN IF EXISTS directive_id;
ALTER TABLE contracts DROP COLUMN IF EXISTS is_directive_orchestrator;
ALTER TABLE contracts DROP COLUMN IF EXISTS spawned_directive_id;
