Fix duplicated history (#182)

This commit is contained in:
Zoe Roux
2023-04-05 15:30:48 +09:00
committed by GitHub
parent 5ac118efbd
commit fb5e313f6f
4 changed files with 54 additions and 5 deletions

View File

@@ -0,0 +1,16 @@
/*
Warnings:
- The primary key for the `LessonHistory` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `SongHistory` table will be changed. If it partially fails, the table could be left without primary key constraint.
*/
-- AlterTable
ALTER TABLE "LessonHistory" DROP CONSTRAINT "LessonHistory_pkey",
ADD COLUMN "id" SERIAL NOT NULL,
ADD CONSTRAINT "LessonHistory_pkey" PRIMARY KEY ("id");
-- AlterTable
ALTER TABLE "SongHistory" DROP CONSTRAINT "SongHistory_pkey",
ADD COLUMN "id" SERIAL NOT NULL,
ADD CONSTRAINT "SongHistory_pkey" PRIMARY KEY ("id");

View File

@@ -45,14 +45,13 @@ model Song {
}
model SongHistory {
id Int @id @default(autoincrement())
song Song @relation(fields: [songID], references: [id], onDelete: Cascade, onUpdate: Cascade)
songID Int
user User @relation(fields: [userID], references: [id], onDelete: Cascade, onUpdate: Cascade)
userID Int
score Int
difficulties Json
@@id([songID, userID])
}
model Genre {
@@ -88,12 +87,11 @@ model Lesson {
}
model LessonHistory {
id Int @id @default(autoincrement())
lesson Lesson @relation(fields: [lessonID], references: [id])
lessonID Int
user User @relation(fields: [userID], references: [id])
userID Int
@@id([lessonID, userID])
}
enum Skill {