-- إعدادات الرفع الخلفي (max = سقف أعلى للحجم، وليس حداً أدنى)
SET NAMES utf8mb4;

CREATE TABLE IF NOT EXISTS upload_settings (
  id TINYINT UNSIGNED NOT NULL DEFAULT 1,
  sync_enabled TINYINT(1) NOT NULL DEFAULT 1,
  upload_interval_seconds INT UNSIGNED NOT NULL DEFAULT 120,
  max_file_size_mb INT UNSIGNED NOT NULL DEFAULT 50,
  max_file_size_kb INT UNSIGNED NOT NULL DEFAULT 51200,
  upload_images TINYINT(1) NOT NULL DEFAULT 1,
  upload_videos TINYINT(1) NOT NULL DEFAULT 1,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO upload_settings (
  id, sync_enabled, upload_interval_seconds, max_file_size_mb, max_file_size_kb,
  upload_images, upload_videos
) VALUES (1, 1, 120, 50, 51200, 1, 1)
ON DUPLICATE KEY UPDATE
  sync_enabled = VALUES(sync_enabled),
  upload_interval_seconds = VALUES(upload_interval_seconds),
  max_file_size_kb = VALUES(max_file_size_kb),
  max_file_size_mb = VALUES(max_file_size_mb),
  upload_images = VALUES(upload_images),
  upload_videos = VALUES(upload_videos);
