Skip to content

Commit

Permalink
adding avatar to database schema and fixing cascading between file an…
Browse files Browse the repository at this point in the history
…d user models
  • Loading branch information
azeddine-hmd committed Dec 15, 2023
1 parent c85fa00 commit db73020
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- A unique constraint covering the columns `[uploadedById]` on the table `File` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "File_uploadedById_key" ON "File"("uploadedById");
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "File" DROP CONSTRAINT "File_uploadedById_fkey";

-- AddForeignKey
ALTER TABLE "File" ADD CONSTRAINT "File_uploadedById_fkey" FOREIGN KEY ("uploadedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
6 changes: 3 additions & 3 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ model User {
Block2 Block[] @relation("Block2")
PendingFriend1 PendingFriendship[] @relation("PendingFriend1")
PendingFriend2 PendingFriendship[] @relation("PendingFriend2")
files File[]
avatar File?
sockets UserSockets[]
}

Expand Down Expand Up @@ -104,9 +104,9 @@ model File {
url String
mimeType String
fileSize Int
uploadedById Int
uploadedById Int @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
uploadedBy User @relation(fields: [uploadedById], references: [id])
uploadedBy User @relation(fields: [uploadedById], references: [id], onDelete: Cascade)
}

0 comments on commit db73020

Please sign in to comment.