Skip to content

Commit

Permalink
Database name changes for the note invites
Browse files Browse the repository at this point in the history
  • Loading branch information
dejanvasic85 committed Dec 30, 2023
1 parent 0037ef2 commit 27a8b0e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 13 deletions.
49 changes: 49 additions & 0 deletions prisma/migrations/20231230121138_note_access_changes/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
Warnings:
- You are about to drop the `NoteAccess` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `NoteAccessInvite` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "NoteAccess" DROP CONSTRAINT "NoteAccess_noteId_fkey";

-- DropForeignKey
ALTER TABLE "NoteAccessInvite" DROP CONSTRAINT "NoteAccessInvite_noteId_fkey";

-- DropTable
DROP TABLE "NoteAccess";

-- DropTable
DROP TABLE "NoteAccessInvite";

-- CreateTable
CREATE TABLE "NoteCollaborator" (
"id" TEXT NOT NULL,
"noteId" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ(6) NOT NULL,

CONSTRAINT "NoteCollaborator_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "NoteInvite" (
"id" TEXT NOT NULL,
"noteId" TEXT NOT NULL,
"email" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ(6) NOT NULL,

CONSTRAINT "NoteInvite_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "NoteCollaborator" ADD CONSTRAINT "NoteCollaborator_noteId_fkey" FOREIGN KEY ("noteId") REFERENCES "Note"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "NoteCollaborator" ADD CONSTRAINT "NoteCollaborator_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "NoteInvite" ADD CONSTRAINT "NoteInvite_noteId_fkey" FOREIGN KEY ("noteId") REFERENCES "Note"("id") ON DELETE CASCADE ON UPDATE CASCADE;
28 changes: 15 additions & 13 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ datasource db {
}

model User {
id String @id
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
authId String @unique
email String @unique
emailVerified Boolean
name String?
picture String?
boards Board[]
id String @id
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
authId String @unique
email String @unique
emailVerified Boolean
name String?
picture String?
boards Board[]
noteCollaborators NoteCollaborator[]
}

model Board {
Expand All @@ -43,20 +44,21 @@ model Note {
colour String?
boardId String
board Board @relation(fields: [boardId], references: [id], onDelete: Cascade)
noteAccess NoteAccess[]
noteAccessInvites NoteAccessInvite[]
noteCollaborators NoteCollaborator[]
noteInvites NoteInvite[]
}

model NoteAccess {
model NoteCollaborator {
id String @id
noteId String
userId String
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
note Note @relation(fields: [noteId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model NoteAccessInvite {
model NoteInvite {
id String @id
noteId String
email String
Expand Down

0 comments on commit 27a8b0e

Please sign in to comment.