-- 音乐库表
CREATE TABLE IF NOT EXISTS `nf_music_library` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `user_id` bigint(20) NOT NULL COMMENT '上传用户ID',
  `title` varchar(255) NOT NULL COMMENT '歌曲标题',
  `artist` varchar(255) DEFAULT NULL COMMENT '艺术家',
  `music_url` varchar(500) NOT NULL COMMENT '音乐文件URL或链接',
  `cover_url` varchar(500) DEFAULT NULL COMMENT '封面图URL',
  `duration` int(11) DEFAULT NULL COMMENT '时长（秒）',
  `upload_type` enum('file','link') NOT NULL DEFAULT 'link' COMMENT '上传类型：file=文件上传，link=链接',
  `is_public` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否公开：1=公开，0=私有',
  `play_count` int(11) NOT NULL DEFAULT 0 COMMENT '播放次数',
  `like_count` int(11) NOT NULL DEFAULT 0 COMMENT '点赞次数',
  `status` enum('pending','approved','rejected') NOT NULL DEFAULT 'approved' COMMENT '审核状态',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted_at` datetime DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_status` (`status`),
  KEY `idx_is_public` (`is_public`),
  KEY `idx_created_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='音乐库表';

-- 用户音乐点赞表
CREATE TABLE IF NOT EXISTS `nf_music_likes` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `user_id` bigint(20) NOT NULL COMMENT '用户ID',
  `music_id` bigint(20) NOT NULL COMMENT '音乐ID',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_user_music` (`user_id`, `music_id`),
  KEY `idx_music_id` (`music_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户音乐点赞表';
