-- Rollback council-related tables

-- Drop triggers first
DROP TRIGGER IF EXISTS update_councils_updated_at ON councils;
DROP TRIGGER IF EXISTS update_council_agents_updated_at ON council_agents;

-- Drop function
DROP FUNCTION IF EXISTS update_updated_at_column();

-- Drop indexes
DROP INDEX IF EXISTS idx_councils_status;
DROP INDEX IF EXISTS idx_councils_created_at;
DROP INDEX IF EXISTS idx_councils_task_id;
DROP INDEX IF EXISTS idx_councils_repository;

DROP INDEX IF EXISTS idx_council_agents_council_id;
DROP INDEX IF EXISTS idx_council_agents_status;
DROP INDEX IF EXISTS idx_council_agents_role_name;
DROP INDEX IF EXISTS idx_council_agents_deployed;

DROP INDEX IF EXISTS idx_council_artifacts_council_id;
DROP INDEX IF EXISTS idx_council_artifacts_type;
DROP INDEX IF EXISTS idx_council_artifacts_status;

DROP INDEX IF EXISTS idx_council_decisions_council_id;
DROP INDEX IF EXISTS idx_council_decisions_type;

-- Drop tables in reverse dependency order
DROP TABLE IF EXISTS council_decisions;
DROP TABLE IF EXISTS council_artifacts;
DROP TABLE IF EXISTS council_agents;
DROP TABLE IF EXISTS councils;