CREATE TABLE IF NOT EXISTS content_updates (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  client_id BIGINT UNSIGNED NOT NULL,
  update_date DATE NOT NULL,
  content_kind ENUM('graphic','video') NOT NULL,
  platforms_json JSON NULL,
  entered_by BIGINT UNSIGNED NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY uq_content_update(client_id,update_date,content_kind),
  INDEX idx_content_update_client_date(client_id,update_date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO settings(setting_group,setting_key,label,sort_order) VALUES
('content_update_platforms','facebook','Facebook',10),
('content_update_platforms','instagram','Instagram',20),
('content_update_platforms','tiktok','TikTok',30)
ON DUPLICATE KEY UPDATE label=VALUES(label);
