Skip to content

Commit

Permalink
Add seen songs relation to User and Song models
Browse files Browse the repository at this point in the history
  • Loading branch information
Advayp committed Feb 2, 2025
1 parent 60fafb1 commit c1b231c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- CreateTable
CREATE TABLE "_SongSeenBy" (
"A" INTEGER NOT NULL,
"B" INTEGER NOT NULL,

CONSTRAINT "_SongSeenBy_AB_pkey" PRIMARY KEY ("A","B")
);

-- CreateIndex
CREATE INDEX "_SongSeenBy_B_index" ON "_SongSeenBy"("B");

-- AddForeignKey
ALTER TABLE "_SongSeenBy" ADD CONSTRAINT "_SongSeenBy_A_fkey" FOREIGN KEY ("A") REFERENCES "Song"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_SongSeenBy" ADD CONSTRAINT "_SongSeenBy_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2 changes: 2 additions & 0 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ model User {
updatedAt DateTime @updatedAt
preferences Genre[]
likedSongs Song[]
seenSongs Song[] @relation("SongSeenBy")
}

model Song {
Expand All @@ -32,6 +33,7 @@ model Song {
likedBy User[]
genreId Int?
genre Genre? @relation(fields: [genreId], references: [id])
seenBy User[] @relation("SongSeenBy")
}


0 comments on commit c1b231c

Please sign in to comment.