| 1 | // This is your Prisma schema file, |
| 2 | // learn more about it in the docs: https://pris.ly/d/prisma-schema |
| 3 | |
| 4 | // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? |
| 5 | // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init |
| 6 | |
| 7 | generator client { |
| 8 | provider = "prisma-client-js" |
| 9 | } |
| 10 | |
| 11 | datasource db { |
| 12 | provider = "postgresql" |
| 13 | url = env("DATABASE_URL") |
| 14 | } |
| 15 | |
| 16 | model Note { |
| 17 | id String @id @default(uuid()) |
| 18 | userId String @map("user_id") |
| 19 | title String |
| 20 | content String @db.Text |
| 21 | isDeleted Boolean @default(false) @map("is_deleted") |
| 22 | createdAt DateTime @default(now()) @map("created_at") |
| 23 | updatedAt DateTime @updatedAt @map("updated_at") |
| 24 | |
| 25 | // Relations |
| 26 | noteTags NoteTag[] |
| 27 | |
| 28 | @@map("notes") |
| 29 | } |
| 30 | |
| 31 | model NoteTag { |
| 32 | noteId String @map("note_id") |
| 33 | tagId String @map("tag_id") // References tag from tags service |
| 34 | |
| 35 | //Relations |
| 36 | note Note @relation(fields: [noteId], references: [id], onDelete: Cascade) |
| 37 | |
| 38 | @@id([noteId, tagId]) |
| 39 | @@map("note_tags") |
| 40 | } |