Add populate script and artist api

This commit is contained in:
Zoe Roux
2022-10-25 02:15:19 +09:00
committed by Bluub
parent 72be838324
commit 89dbee0b17
22 changed files with 461 additions and 104 deletions

View File

@@ -0,0 +1,10 @@
/*
Warnings:
- Added the required column `midiPath` to the `Song` table without a default value. This is not possible if the table is not empty.
- Added the required column `musicXmlPath` to the `Song` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Song" ADD COLUMN "midiPath" TEXT NOT NULL,
ADD COLUMN "musicXmlPath" TEXT NOT NULL;

View File

@@ -0,0 +1,8 @@
/*
Warnings:
- A unique constraint covering the columns `[name]` on the table `Album` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "Album_name_key" ON "Album"("name");

View File

@@ -0,0 +1,12 @@
/*
Warnings:
- A unique constraint covering the columns `[name]` on the table `Artist` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[name]` on the table `Genre` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "Artist_name_key" ON "Artist"("name");
-- CreateIndex
CREATE UNIQUE INDEX "Genre_name_key" ON "Genre"("name");

View File

@@ -1,87 +1,89 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
username String @unique
password String
email String
LessonHistory LessonHistory[]
id Int @id @default(autoincrement())
username String @unique
password String
email String
LessonHistory LessonHistory[]
}
model Song {
id Int @id @default(autoincrement())
name String @unique
artistId Int?
artist Artist? @relation(fields: [artistId], references: [id])
albumId Int?
album Album? @relation(fields: [albumId], references: [id])
genreId Int?
genre Genre? @relation(fields: [genreId], references: [id])
difficulties Json
id Int @id @default(autoincrement())
name String @unique
midiPath String
musicXmlPath String
artistId Int?
artist Artist? @relation(fields: [artistId], references: [id])
albumId Int?
album Album? @relation(fields: [albumId], references: [id])
genreId Int?
genre Genre? @relation(fields: [genreId], references: [id])
difficulties Json
}
model Genre {
id Int @id @default(autoincrement())
name String
id Int @id @default(autoincrement())
name String @unique
Song Song[]
Song Song[]
}
model Artist {
id Int @id @default(autoincrement())
name String
id Int @id @default(autoincrement())
name String @unique
Song Song[]
Song Song[]
}
model Album {
id Int @id @default(autoincrement())
name String
id Int @id @default(autoincrement())
name String @unique
Song Song[]
Song Song[]
}
model Lesson {
id Int @id @default(autoincrement())
name String
description String
requiredLevel Int
mainSkill Skill
LessonHistory LessonHistory[]
id Int @id @default(autoincrement())
name String
description String
requiredLevel Int
mainSkill Skill
LessonHistory LessonHistory[]
}
model LessonHistory {
lesson Lesson @relation(fields: [lessonID], references: [id])
lessonID Int
user User @relation(fields: [userID], references: [id])
userID Int
lesson Lesson @relation(fields: [lessonID], references: [id])
lessonID Int
user User @relation(fields: [userID], references: [id])
userID Int
@@id([lessonID, userID])
@@id([lessonID, userID])
}
enum Skill {
TwoHands
Rhythm
NoteCombo
Arpeggio
Distance
LeftHand
RightHand
LeadHandChange
ChordComplexity
ChordTiming
Length
PedalPoint
Precision
TwoHands
Rhythm
NoteCombo
Arpeggio
Distance
LeftHand
RightHand
LeadHandChange
ChordComplexity
ChordTiming
Length
PedalPoint
Precision
@@map("DifficultyPoint")
@@map("DifficultyPoint")
}