-- Create soccer_settings table for persistent configuration storage
CREATE TABLE IF NOT EXISTS `soccer_settings` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `key` VARCHAR(255) NOT NULL UNIQUE,
    `value` TEXT NOT NULL,
    `type` VARCHAR(50) NOT NULL DEFAULT 'string' COMMENT 'string, numeric, or boolean',
    `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    INDEX `idx_key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Insert default settings (only if they don't exist)
INSERT IGNORE INTO `soccer_settings` (`key`, `value`, `type`, `created_at`, `updated_at`) VALUES
('minimum_stake', '10', 'numeric', NOW(), NOW()),
('maximum_stake', '100000', 'numeric', NOW(), NOW()),
('maximum_payout', '1000000', 'numeric', NOW(), NOW()),
('minimum_odds', '1.01', 'numeric', NOW(), NOW()),
('maximum_odds', '1000', 'numeric', NOW(), NOW()),
('maximum_selections', '50', 'numeric', NOW(), NOW()),
('tax_percentage', '7.5', 'numeric', NOW(), NOW()),
('commission_percentage', '10', 'numeric', NOW(), NOW()),
('allow_live_betting', '1', 'boolean', NOW(), NOW()),
('betting_enabled', '1', 'boolean', NOW(), NOW());

-- Show created settings
SELECT * FROM soccer_settings;
