Ai_GirlFriend/开发/2026年2月4日/音乐库唱歌视频数据库修改.sql
2026-02-04 18:47:56 +08:00

26 lines
1.1 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 音乐库唱歌视频功能 - 数据库修改脚本
-- 创建时间: 2026-02-04
-- 说明: 为 nf_sing_song_video 表添加音乐库关联字段
USE fastadmin;
-- 1. 为 nf_sing_song_video 表添加字段
ALTER TABLE nf_sing_song_video
ADD COLUMN music_library_id BIGINT NULL COMMENT '音乐库ID如果来自音乐库' AFTER song_id,
ADD COLUMN music_source VARCHAR(20) DEFAULT 'system' COMMENT '音乐来源system=系统歌曲库, library=音乐库' AFTER music_library_id;
-- 2. 为 fa_song_library 表添加 audio_hash 字段(用于去重)
ALTER TABLE fa_song_library
ADD COLUMN audio_hash VARCHAR(64) NULL COMMENT '音频URL的MD5哈希用于去重' AFTER audio_url;
-- 3. 为现有记录设置默认值
UPDATE nf_sing_song_video SET music_source = 'system' WHERE music_source IS NULL;
-- 4. 创建索引(可选,提升查询性能)
CREATE INDEX idx_music_library_id ON nf_sing_song_video(music_library_id);
CREATE INDEX idx_music_source ON nf_sing_song_video(music_source);
CREATE INDEX idx_audio_hash ON fa_song_library(audio_hash);
-- 完成
SELECT '数据库修改完成!' AS message;