-- Create app_settings table for storing app version and download links
CREATE TABLE IF NOT EXISTS `app_settings` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `setting_key` varchar(100) NOT NULL,
    `setting_value` text,
    `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
    `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `setting_key` (`setting_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- Insert default app version (update this number when releasing new versions)
INSERT INTO `app_settings` (`setting_key`, `setting_value`) 
VALUES ('app_version', '1')
ON DUPLICATE KEY UPDATE `setting_value` = '1';

-- Per-platform forced update (1 = prompt when backend version > app; 0 = do not block that platform)
INSERT INTO `app_settings` (`setting_key`, `setting_value`)
VALUES ('require_update_android', '1')
ON DUPLICATE KEY UPDATE `setting_key` = `setting_key`;

INSERT INTO `app_settings` (`setting_key`, `setting_value`)
VALUES ('require_update_ios', '1')
ON DUPLICATE KEY UPDATE `setting_key` = `setting_key`;

-- Insert download links (update these URLs with your actual download links)
-- APK Direct Download
INSERT INTO `app_settings` (`setting_key`, `setting_value`) 
VALUES ('download_link_apk', 'https://your-server.com/apps/betting_tips.apk')
ON DUPLICATE KEY UPDATE `setting_value` = 'https://your-server.com/apps/betting_tips.apk';

-- Google Play Store
INSERT INTO `app_settings` (`setting_key`, `setting_value`) 
VALUES ('download_link_googlePlay', 'https://play.google.com/store/apps/details?id=com.sports.bettips')
ON DUPLICATE KEY UPDATE `setting_value` = 'https://play.google.com/store/apps/details?id=com.sports.bettips';

-- Huawei AppGallery
INSERT INTO `app_settings` (`setting_key`, `setting_value`) 
VALUES ('download_link_huawei', 'https://appgallery.huawei.com/app/your-app-id')
ON DUPLICATE KEY UPDATE `setting_value` = 'https://appgallery.huawei.com/app/your-app-id';

-- OPPO App Market
INSERT INTO `app_settings` (`setting_key`, `setting_value`) 
VALUES ('download_link_oppo', 'https://store.oppo.com/app/your-app-id')
ON DUPLICATE KEY UPDATE `setting_value` = 'https://store.oppo.com/app/your-app-id';

-- iOS App Store
INSERT INTO `app_settings` (`setting_key`, `setting_value`) 
VALUES ('download_link_appStore', 'https://apps.apple.com/app/your-app-id')
ON DUPLICATE KEY UPDATE `setting_value` = 'https://apps.apple.com/app/your-app-id';

