Add song & search history (#165)

This commit is contained in:
Zoe Roux
2023-03-01 13:29:33 +09:00
committed by GitHub
parent df85d0cfa7
commit f1a3f6e46a
30 changed files with 553 additions and 126 deletions
@@ -0,0 +1,13 @@
-- CreateTable
CREATE TABLE "SongHistory" (
"songID" INTEGER NOT NULL,
"userID" INTEGER NOT NULL,
CONSTRAINT "SongHistory_pkey" PRIMARY KEY ("songID","userID")
);
-- AddForeignKey
ALTER TABLE "SongHistory" ADD CONSTRAINT "SongHistory_songID_fkey" FOREIGN KEY ("songID") REFERENCES "Song"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "SongHistory" ADD CONSTRAINT "SongHistory_userID_fkey" FOREIGN KEY ("userID") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
@@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `score` to the `SongHistory` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "SongHistory" ADD COLUMN "score" INTEGER NOT NULL;
@@ -0,0 +1,14 @@
/*
Warnings:
- Added the required column `difficulties` to the `SongHistory` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "SongHistory" DROP CONSTRAINT "SongHistory_userID_fkey";
-- AlterTable
ALTER TABLE "SongHistory" ADD COLUMN "difficulties" JSONB NOT NULL;
-- AddForeignKey
ALTER TABLE "SongHistory" ADD CONSTRAINT "SongHistory_userID_fkey" FOREIGN KEY ("userID") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,11 @@
-- CreateTable
CREATE TABLE "SearchHistory" (
"id" SERIAL NOT NULL,
"query" TEXT NOT NULL,
"userId" INTEGER,
CONSTRAINT "SearchHistory_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "SearchHistory" ADD CONSTRAINT "SearchHistory_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `type` to the `SearchHistory` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "SearchHistory" ADD COLUMN "type" TEXT NOT NULL;
@@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "SongHistory" DROP CONSTRAINT "SongHistory_songID_fkey";
-- AddForeignKey
ALTER TABLE "SongHistory" ADD CONSTRAINT "SongHistory_songID_fkey" FOREIGN KEY ("songID") REFERENCES "Song"("id") ON DELETE CASCADE ON UPDATE CASCADE;