feat(migration): add migration for SpecialSong model
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "SpecialSong" (
|
||||||
|
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"specialId" INTEGER NOT NULL,
|
||||||
|
"songId" INTEGER NOT NULL,
|
||||||
|
"startTime" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"order" INTEGER,
|
||||||
|
CONSTRAINT "SpecialSong_specialId_fkey" FOREIGN KEY ("specialId") REFERENCES "Special" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT "SpecialSong_songId_fkey" FOREIGN KEY ("songId") REFERENCES "Song" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Migrate data from _SongToSpecial to SpecialSong
|
||||||
|
INSERT INTO "SpecialSong" ("specialId", "songId", "startTime")
|
||||||
|
SELECT "B" as "specialId", "A" as "songId", 0 as "startTime"
|
||||||
|
FROM "_SongToSpecial";
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "_SongToSpecial";
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "SpecialSong_specialId_songId_key" ON "SpecialSong"("specialId", "songId");
|
||||||
Reference in New Issue
Block a user