/*
  Warnings:

  - You are about to drop the column `artist` on the `SongRequest` table. All the data in the column will be lost.
  - You are about to drop the column `song` on the `SongRequest` table. All the data in the column will be lost.
  - Added the required column `songId` to the `SongRequest` table without a default value. This is not possible if the table is not empty.

*/
-- AlterTable
ALTER TABLE `SongRequest`
    ADD COLUMN `songId` INTEGER NULL, -- dibuat nullable dulu
    ADD COLUMN `temp_song` VARCHAR(255), -- backup kolom song lama
    ADD COLUMN `temp_artist` VARCHAR(255); -- backup kolom artist lama

-- Copy data lama
UPDATE `SongRequest` SET `temp_song` = `song`, `temp_artist` = `artist`;

-- (Nanti setelah update data di DB sesuai relasi Song, kamu bisa hapus kolom-kolom sementara ini)

-- AddForeignKey
ALTER TABLE `SongRequest` ADD CONSTRAINT `SongRequest_songId_fkey` FOREIGN KEY (`songId`) REFERENCES `Song`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- Tambahkan juga FK talent kalau belum ada
ALTER TABLE `SongRequest` ADD CONSTRAINT `SongRequest_talentId_fkey` FOREIGN KEY (`talentId`) REFERENCES `Talent`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
