-- 短视频去水印调用日志
CREATE TABLE IF NOT EXISTS `video_parse_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `deleted_at` datetime DEFAULT NULL,
  `mini_program_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `request_content` text,
  `parsed_url` varchar(500) DEFAULT NULL,
  `third_party_status` int DEFAULT NULL,
  `third_party_payload` json DEFAULT NULL,
  `free_quota_used` tinyint(1) NOT NULL DEFAULT '1',
  `duration_ms` int DEFAULT NULL,
  `error_message` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_video_parse_user_date` (`mini_program_id`,`user_id`,`created_at`),
  KEY `idx_video_parse_free` (`mini_program_id`,`user_id`,`free_quota_used`,`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 每日广告解锁记录
CREATE TABLE IF NOT EXISTS `video_parse_unlocks` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `deleted_at` datetime DEFAULT NULL,
  `mini_program_id` bigint unsigned NOT NULL,
  `user_id` bigint unsigned NOT NULL,
  `unlock_date` date NOT NULL,
  `ad_watched_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_video_unlock_date` (`mini_program_id`,`user_id`,`unlock_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
