diff --git a/.gitignore b/.gitignore index 1e86142..378d91e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ report.html log.html .expo node_modules/ -./front/coverage \ No newline at end of file +./front/coverage +.venv diff --git a/back/prisma/migrations/20230405061222_/migration.sql b/back/prisma/migrations/20230405061222_/migration.sql new file mode 100644 index 0000000..068754d --- /dev/null +++ b/back/prisma/migrations/20230405061222_/migration.sql @@ -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"); diff --git a/back/prisma/schema.prisma b/back/prisma/schema.prisma index 2bbe9a1..77708f4 100644 --- a/back/prisma/schema.prisma +++ b/back/prisma/schema.prisma @@ -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 { diff --git a/back/test/robot/history/history.robot b/back/test/robot/history/history.robot index 4306d06..b4aa6c8 100644 --- a/back/test/robot/history/history.robot +++ b/back/test/robot/history/history.robot @@ -37,6 +37,40 @@ Create and get an history record [Teardown] Run Keywords DELETE /users/${userID} ... AND DELETE /song/${song.body.id} +Create and get a duplicated history record + [Documentation] Create an history item + &{song}= POST + ... /song + ... {"name": "Mama mia", "difficulties": {}, "midiPath": "/musics/Beethoven-125-4.midi", "musicXmlPath": "/musics/Beethoven-125-4.mxl"} + Output + ${userID}= RegisterLogin wowuser + + &{history}= POST + ... /history + ... { "userID": ${userID}, "songID": ${song.body.id}, "score": 55, "difficulties": {} } + Output + Integer response status 201 + + &{history2}= POST + ... /history + ... { "userID": ${userID}, "songID": ${song.body.id}, "score": 65, "difficulties": {} } + Output + Integer response status 201 + + &{res}= GET /history + Output + Integer response status 200 + Array response body + Integer $[0].userID ${userID} + Integer $[0].songID ${song.body.id} + Integer $[0].score 55 + Integer $[1].userID ${userID} + Integer $[1].songID ${song.body.id} + Integer $[1].score 65 + + [Teardown] Run Keywords DELETE /users/${userID} + ... AND DELETE /song/${song.body.id} + Create and get a search history record [Documentation] Create a search history item ${userID}= RegisterLogin historyqueryuser