-- Rollback task-team integration enhancements

-- Drop task executions table
DROP TABLE IF EXISTS task_executions;

-- Drop triggers and functions
DROP TRIGGER IF EXISTS update_task_executions_updated_at ON task_executions;
DROP FUNCTION IF EXISTS update_updated_at_column();

-- Remove agent performance columns
ALTER TABLE agents DROP COLUMN IF EXISTS workload_capacity;
ALTER TABLE agents DROP COLUMN IF EXISTS current_tasks; 
ALTER TABLE agents DROP COLUMN IF EXISTS success_rate;

-- Remove team composition data column
ALTER TABLE teams DROP COLUMN IF EXISTS composition_data;
ALTER TABLE teams DROP COLUMN IF EXISTS task_id;

-- Remove repository_id from tasks if it was added by this migration
-- (Leave it if it existed before since other migrations might depend on it)

-- Drop indexes
DROP INDEX IF EXISTS idx_agents_workload;
DROP INDEX IF EXISTS idx_agents_performance;
DROP INDEX IF EXISTS idx_teams_task_id;