-- Migration: Add Order 10 rule for Cat A
-- Rule: High Frequency Chargeback Merchant's
-- Date: 2026-03-27

START TRANSACTION;

-- Insert the correct rule at order 10 for Cat A
INSERT INTO risk_rules (
  name,
  description,
  category,
  rule_type,
  execution_order,
  mcc_codes,
  parameters,
  enabled,
  inserted_at,
  updated_at
) VALUES (
  'High Frequency Chargeback Merchant''s',
  'Transaction coming from high frequency chargeback Merchant''s having 2 or more chargeback received in last 30 days (Are highlighted in daily risk report for scrutiny and further actions)',
  'Cat A',
  'hold',
  10,
  '{"all": true}',
  '{"chargeback_count_threshold": 2, "period_days": 30, "action": "hold_for_scrutiny"}',
  1,
  NOW(),
  NOW()
);

-- Verify insertion
SELECT 
  execution_order,
  name,
  category,
  rule_type,
  enabled
FROM risk_rules 
WHERE execution_order = 10 
ORDER BY category;

-- Count rules per category
SELECT 
  category,
  COUNT(*) as total_rules
FROM risk_rules 
GROUP BY category 
ORDER BY category;

COMMIT;
