Last active
February 6, 2025 14:11
-
-
Save Aryan3212/e0babf0355b41a262305c37997cc241f to your computer and use it in GitHub Desktop.
Prisma schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
datasource db { | |
provider = "postgresql" | |
url = env("DATABASE_URL") | |
relationMode = "prisma" | |
} | |
// This is causing errors | |
// Current running issues and related PRs: | |
// https://github.com/prisma/prisma/issues/17649 | |
// https://github.com/prisma/prisma/issues/15759 | |
// https://github.com/prisma/prisma-engines/pull/4116 | |
model Note { | |
id String @id @unique @default(dbgenerated("gen_random_uuid()")) | |
userId String | |
body Json? | |
title String @default("") | |
summary String @default("") | |
card Card? | |
user User? @relation(fields: [userId], references: [id]) | |
deleted Boolean @default(false) | |
createdAt DateTime @default(now()) @db.Timestamptz @map("created_at") | |
updatedAt DateTime @default(now()) @db.Timestamptz @updatedAt @map("updated_at") | |
parentNote Note? @relation("ChildNotes", fields: [parentNoteId], references: [id], onDelete: NoAction, onUpdate: Cascade) | |
childNotes Note[] @relation("ChildNotes") | |
parentNoteId String? | |
@@index([userId]) | |
@@index([parentNoteId]) | |
} | |
// This works but not what I want | |
model Note { | |
id String @id @unique @default(dbgenerated("gen_random_uuid()")) | |
userId String | |
body Json? | |
title String @default("") | |
summary String @default("") | |
card Card? | |
user User? @relation(fields: [userId], references: [id]) | |
deleted Boolean @default(false) | |
createdAt DateTime @default(now()) @db.Timestamptz @map("created_at") | |
updatedAt DateTime @default(now()) @db.Timestamptz @updatedAt @map("updated_at") | |
parentNoteId String? | |
parentNote Note? @relation("ChildNotes", fields: [parentNoteId], references: [id], onDelete: Restrict, onUpdate: Restrict) | |
childNotes Note[] @relation("ChildNotes") | |
@@index([userId]) | |
@@index([parentNoteId]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment