Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create db schema for project/scene/music submissions #93

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"devDependencies": {
"@good-dog/prettier": "workspace:*",
"@turbo/gen": "^2.1.2",
"@turbo/gen": "2.1.2",
"dotenv-cli": "^7.4.2",
"turbo": "2.1.2",
"typescript": "5.4.5"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
Warnings:

- The required column `id` was added to the `MusicianGroupMember` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required.

*/
-- AlterTable
ALTER TABLE "MusicianGroupMember" ADD COLUMN "id" TEXT NOT NULL,
ADD CONSTRAINT "MusicianGroupMember_pkey" PRIMARY KEY ("id");

-- CreateTable
CREATE TABLE "ProjectSubmission" (
"projectId" TEXT NOT NULL,
"description" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deadline" TIMESTAMP(3) NOT NULL,
"videoLink" TEXT NOT NULL DEFAULT '',
"additionalInfo" TEXT NOT NULL DEFAULT '',

CONSTRAINT "ProjectSubmission_pkey" PRIMARY KEY ("projectId")
);

-- CreateTable
CREATE TABLE "SceneSubmission" (
"sceneId" TEXT NOT NULL,
"description" TEXT NOT NULL,
"musicType" TEXT NOT NULL,
"similarSongs" TEXT NOT NULL DEFAULT '',
"additionalInfo" TEXT NOT NULL DEFAULT '',
"projectId" TEXT NOT NULL,

CONSTRAINT "SceneSubmission_pkey" PRIMARY KEY ("sceneId")
);

-- CreateTable
CREATE TABLE "MusicSubmission" (
"musicId" TEXT NOT NULL,
"songName" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"artistId" TEXT NOT NULL,
"songLink" TEXT NOT NULL,
"genre" TEXT NOT NULL,
"groupId" TEXT NOT NULL,
"additionalInfo" TEXT NOT NULL DEFAULT '',

CONSTRAINT "MusicSubmission_pkey" PRIMARY KEY ("musicId")
);

-- CreateTable
CREATE TABLE "_songWriters" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "_songWriters_AB_unique" ON "_songWriters"("A", "B");

-- CreateIndex
CREATE INDEX "_songWriters_B_index" ON "_songWriters"("B");

-- AddForeignKey
ALTER TABLE "ProjectSubmission" ADD CONSTRAINT "ProjectSubmission_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "SceneSubmission" ADD CONSTRAINT "SceneSubmission_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "ProjectSubmission"("projectId") ON DELETE NO ACTION ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MusicSubmission" ADD CONSTRAINT "MusicSubmission_artistId_fkey" FOREIGN KEY ("artistId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MusicSubmission" ADD CONSTRAINT "MusicSubmission_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "MusicianGroup"("groupId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_songWriters" ADD CONSTRAINT "_songWriters_A_fkey" FOREIGN KEY ("A") REFERENCES "MusicSubmission"("musicId") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_songWriters" ADD CONSTRAINT "_songWriters_B_fkey" FOREIGN KEY ("B") REFERENCES "MusicianGroupMember"("id") ON DELETE CASCADE ON UPDATE CASCADE;
84 changes: 63 additions & 21 deletions packages/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,23 @@ enum Role {
}

model User {
userId String @id @default(uuid()) @map("id")
email String @unique
hashedPassword String @map("password")
userId String @id @default(uuid()) @map("id")
email String @unique
hashedPassword String @map("password")
firstName String
lastName String
stageName String?
role Role
isSongWriter Boolean @default(false)
isAscapAffiliated Boolean @default(false)
isBmiAffiliated Boolean @default(false)
isSongWriter Boolean @default(false)
isAscapAffiliated Boolean @default(false)
isBmiAffiliated Boolean @default(false)
musicianGroups MusicianGroup[]
passwordResetReq PasswordResetReq?
sessions Session[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
project ProjectSubmission[]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename to projectSubmission? Shouldn't change the migration file.

musicSubmission MusicSubmission[]
}

model Session {
Expand Down Expand Up @@ -65,27 +67,67 @@ model PasswordResetReq {
}

model MusicianGroup {
groupId String @id @default(uuid())
organizerId String // The user that created the group
organizer User @relation(fields: [organizerId], references: [userId], onDelete: Cascade)
name String
groupMembers MusicianGroupMember[] // Does not contain the user that created the group
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
groupId String @id @default(uuid())
organizerId String // The user that created the group
organizer User @relation(fields: [organizerId], references: [userId], onDelete: Cascade)
name String
groupMembers MusicianGroupMember[] // Does not contain the user that created the group
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
musicSubmissions MusicSubmission[]
}

model MusicianGroupMember {
id String @id @default(uuid()) @map("id")
groupId String
group MusicianGroup @relation(fields: [groupId], references: [groupId], onDelete: Cascade)
group MusicianGroup @relation(fields: [groupId], references: [groupId], onDelete: Cascade)
firstName String
lastName String
stageName String?
email String
isSongWriter Boolean @default(false)
isAscapAffiliated Boolean @default(false)
isBmiAffiliated Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
isSongWriter Boolean @default(false)
isAscapAffiliated Boolean @default(false)
isBmiAffiliated Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
musicSubmissions MusicSubmission[] @relation("songWriters")

@@unique([groupId, email])
}

model ProjectSubmission {
projectId String @id @default(uuid())
projectOwner User @relation(fields: [projectId], references: [userId], onDelete: Cascade)
description String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
scenes SceneSubmission[]
deadline DateTime
videoLink String @default("")
additionalInfo String @default("")
}

model SceneSubmission {
sceneId String @id @default(uuid())
description String
musicType String
similarSongs String @default("")
additionalInfo String @default("")
projectId String
Project ProjectSubmission @relation(fields: [projectId], references: [projectId], onDelete: NoAction)
}

model MusicSubmission {
musicId String @id @default(uuid())
songName String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
artist User @relation(fields: [artistId], references: [userId], onDelete: Cascade)
artistId String
songLink String
genre String
group MusicianGroup @relation(fields: [groupId], references: [groupId])
groupId String
songwriters MusicianGroupMember[] @relation("songWriters")
additionalInfo String @default("")
}
Loading