-- Migration: Create payment_gateways table
-- Description: Stores payment gateway configurations (Paystack, Bitcoin, etc.)
-- Date: 2026-01-26

CREATE TABLE IF NOT EXISTS payment_gateways (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100) NOT NULL UNIQUE,
  type ENUM('automatic', 'manual') DEFAULT 'automatic',
  currency VARCHAR(10),
  min_amount DECIMAL(10, 2),
  max_amount DECIMAL(10, 2),
  conversion_rate DECIMAL(10, 4),
  fixed_charge DECIMAL(10, 2),
  percentage_charge DECIMAL(5, 2),
  config JSON,
  status ENUM('enabled', 'disabled') DEFAULT 'enabled',
  instructions TEXT,
  user_inputs JSON,
  display_order INT DEFAULT 0,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

  INDEX idx_name (name),
  INDEX idx_type (type),
  INDEX idx_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Insert default payment gateways
-- Paystack removed - New payment methods will be added via migration
INSERT IGNORE INTO payment_gateways (name, type, status, display_order) VALUES
  ('Bank Transfer', 'manual', 'disabled', 1);
