-- ================================================================================================
-- Migration 045 DOWN: Rollback Wave D Regime Tracking Tables
-- Removes all Wave D regime detection and adaptive strategy infrastructure
-- ================================================================================================

-- Revoke permissions first
REVOKE EXECUTE ON FUNCTION get_regime_performance FROM foxhunt;
REVOKE EXECUTE ON FUNCTION get_regime_transition_matrix FROM foxhunt;
REVOKE EXECUTE ON FUNCTION get_latest_regime FROM foxhunt;
REVOKE USAGE, SELECT ON SEQUENCE adaptive_strategy_metrics_id_seq FROM foxhunt;
REVOKE USAGE, SELECT ON SEQUENCE regime_transitions_id_seq FROM foxhunt;
REVOKE USAGE, SELECT ON SEQUENCE regime_states_id_seq FROM foxhunt;
REVOKE SELECT, INSERT, UPDATE ON adaptive_strategy_metrics FROM foxhunt;
REVOKE SELECT, INSERT ON regime_transitions FROM foxhunt;
REVOKE SELECT, INSERT, UPDATE ON regime_states FROM foxhunt;

-- Drop functions (in reverse order of dependencies)
DROP FUNCTION IF EXISTS get_regime_performance(TEXT, INTEGER);
DROP FUNCTION IF EXISTS get_regime_transition_matrix(TEXT, INTEGER);
DROP FUNCTION IF EXISTS get_latest_regime(TEXT);

-- Drop tables (in reverse order of creation)
DROP TABLE IF EXISTS adaptive_strategy_metrics CASCADE;
DROP TABLE IF EXISTS regime_transitions CASCADE;
DROP TABLE IF EXISTS regime_states CASCADE;

-- ================================================================================================
-- END MIGRATION 045 DOWN
-- ================================================================================================
