USE fastadmin;

ALTER TABLE nf_sing_song_video
ADD COLUMN music_library_id BIGINT NULL AFTER song_id,
ADD COLUMN music_source VARCHAR(20) DEFAULT 'system' AFTER music_library_id;

ALTER TABLE nf_song_library
ADD COLUMN audio_hash VARCHAR(64) NULL AFTER audio_url;

UPDATE nf_sing_song_video SET music_source = 'system' WHERE music_source IS NULL;

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 nf_song_library(audio_hash);

SELECT 'Database update completed!' AS message;
