From 4b6f0f95265b7a535a097103745d127801608fae Mon Sep 17 00:00:00 2001 From: sepehr Date: Sun, 26 Apr 2026 15:02:15 +0200 Subject: [PATCH] fix: sync MCP schema exactly with memento-note (full copy) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copy all models used by MCP tools with every field, relation, and index from memento-note/prisma/schema.prisma. No more guessing which relations are needed — it's an exact subset. Co-Authored-By: Claude Opus 4.7 --- mcp-server/prisma/schema.prisma | 274 ++++++++++++++++++++------------ 1 file changed, 170 insertions(+), 104 deletions(-) diff --git a/mcp-server/prisma/schema.prisma b/mcp-server/prisma/schema.prisma index 77c757c..48f67ca 100644 --- a/mcp-server/prisma/schema.prisma +++ b/mcp-server/prisma/schema.prisma @@ -1,3 +1,9 @@ +// ============================================================================ +// MCP Server Schema — exact copy from memento-note (source of truth) +// Only includes models used by MCP tools. +// Do NOT modify independently — always sync with memento-note/prisma/schema.prisma +// ============================================================================ + generator client { provider = "prisma-client-js" output = "../node_modules/.prisma/client" @@ -9,79 +15,7 @@ datasource db { url = env("DATABASE_URL") } -model Note { - id String @id @default(cuid()) - title String? - content String - color String @default("default") - isPinned Boolean @default(false) - isArchived Boolean @default(false) - trashedAt DateTime? - type String @default("text") - dismissedFromRecent Boolean @default(false) - checkItems String? - labels String? - images String? - links String? - reminder DateTime? - isReminderDone Boolean @default(false) - reminderRecurrence String? - reminderLocation String? - isMarkdown Boolean @default(false) - size String @default("small") - sharedWith String? - userId String? - order Int @default(0) - notebookId String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - contentUpdatedAt DateTime @default(now()) - autoGenerated Boolean? - aiProvider String? - aiConfidence Int? - language String? - languageConfidence Float? - lastAiAnalysis DateTime? - noteEmbedding NoteEmbedding? -} - -model NoteEmbedding { - id String @id @default(cuid()) - noteId String @unique - embedding String - createdAt DateTime @default(now()) - note Note @relation(fields: [noteId], references: [id], onDelete: Cascade) - - @@index([noteId]) -} - -model Notebook { - id String @id @default(cuid()) - name String - icon String? - color String? - order Int - userId String - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - notes Note[] - labels Label[] -} - -model Label { - id String @id @default(cuid()) - name String - color String @default("gray") - notebookId String? - userId String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - notebook Notebook? @relation(fields: [notebookId], references: [id], onDelete: Cascade) - - @@unique([notebookId, name]) - @@index([notebookId]) - @@index([userId]) -} +// ── Core models (used by MCP tools) ───────────────────────────────────────── model User { id String @id @default(cuid()) @@ -97,8 +31,136 @@ model User { resetTokenExpiry DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + accounts Account[] + aiFeedback AiFeedback[] + labels Label[] + memoryEchoInsights MemoryEchoInsight[] + notes Note[] + sentShares NoteShare[] @relation("SentShares") + receivedShares NoteShare[] @relation("ReceivedShares") + notebooks Notebook[] + sessions Session[] + aiSettings UserAISettings? } +model Notebook { + id String @id @default(cuid()) + name String + icon String? + color String? + order Int + userId String + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + labels Label[] + notes Note[] + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@index([userId, order]) + @@index([userId]) +} + +model Label { + id String @id @default(cuid()) + name String + color String @default("gray") + notebookId String? + userId String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + user User? @relation(fields: [userId], references: [id], onDelete: Cascade) + notebook Notebook? @relation(fields: [notebookId], references: [id], onDelete: Cascade) + notes Note[] @relation("LabelToNote") + + @@unique([notebookId, name]) + @@index([notebookId]) + @@index([userId]) +} + +model Note { + id String @id @default(cuid()) + title String? + content String + color String @default("default") + isPinned Boolean @default(false) + isArchived Boolean @default(false) + trashedAt DateTime? + type String @default("text") + dismissedFromRecent Boolean @default(false) + checkItems String? + labels String? + images String? + links String? + reminder DateTime? + isReminderDone Boolean @default(false) + reminderRecurrence String? + reminderLocation String? + isMarkdown Boolean @default(false) + size String @default("small") + sharedWith String? + userId String? + order Int @default(0) + notebookId String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + contentUpdatedAt DateTime @default(now()) + autoGenerated Boolean? + aiProvider String? + aiConfidence Int? + language String? + languageConfidence Float? + lastAiAnalysis DateTime? + aiFeedback AiFeedback[] + memoryEchoAsNote2 MemoryEchoInsight[] @relation("EchoNote2") + memoryEchoAsNote1 MemoryEchoInsight[] @relation("EchoNote1") + notebook Notebook? @relation(fields: [notebookId], references: [id]) + user User? @relation(fields: [userId], references: [id], onDelete: Cascade) + shares NoteShare[] + labelRelations Label[] @relation("LabelToNote") + noteEmbedding NoteEmbedding? + + @@index([isPinned]) + @@index([isArchived]) + @@index([trashedAt]) + @@index([order]) + @@index([reminder]) + @@index([userId]) + @@index([userId, notebookId]) +} + +model NoteEmbedding { + id String @id @default(cuid()) + noteId String @unique + embedding String + createdAt DateTime @default(now()) + note Note @relation(fields: [noteId], references: [id], onDelete: Cascade) + + @@index([noteId]) +} + +model NoteShare { + id String @id @default(cuid()) + noteId String + userId String + sharedBy String + status String @default("pending") + permission String @default("view") + notifiedAt DateTime? + respondedAt DateTime? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + sharer User @relation("SentShares", fields: [sharedBy], references: [id], onDelete: Cascade) + user User @relation("ReceivedShares", fields: [userId], references: [id], onDelete: Cascade) + note Note @relation(fields: [noteId], references: [id], onDelete: Cascade) + + @@unique([noteId, userId]) + @@index([userId]) + @@index([status]) + @@index([sharedBy]) +} + +// ── Supporting models (used for auth, AI features, config) ────────────────── + model Account { userId String type String @@ -113,6 +175,7 @@ model Account { session_state String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@id([provider, providerAccountId]) } @@ -123,6 +186,7 @@ model Session { expires DateTime createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + user User @relation(fields: [userId], references: [id], onDelete: Cascade) } model VerificationToken { @@ -133,21 +197,6 @@ model VerificationToken { @@id([identifier, token]) } -model NoteShare { - id String @id @default(cuid()) - noteId String - userId String - sharedBy String - status String @default("pending") - permission String @default("view") - notifiedAt DateTime? - respondedAt DateTime? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - - @@unique([noteId, userId]) -} - model SystemConfig { key String @id value String @@ -162,7 +211,13 @@ model AiFeedback { originalContent String correctedContent String? metadata String? - createdAt DateTime @default(now()) + createdAt DateTime @default(now()) + user User? @relation(fields: [userId], references: [id], onDelete: Cascade) + note Note @relation(fields: [noteId], references: [id], onDelete: Cascade) + + @@index([noteId]) + @@index([userId]) + @@index([feature]) } model MemoryEchoInsight { @@ -176,24 +231,35 @@ model MemoryEchoInsight { viewed Boolean @default(false) feedback String? dismissed Boolean @default(false) + user User? @relation(fields: [userId], references: [id], onDelete: Cascade) + note2 Note @relation("EchoNote2", fields: [note2Id], references: [id], onDelete: Cascade) + note1 Note @relation("EchoNote1", fields: [note1Id], references: [id], onDelete: Cascade) @@unique([userId, insightDate]) + @@index([userId, insightDate]) + @@index([userId, dismissed]) } model UserAISettings { - userId String @id - titleSuggestions Boolean @default(true) - semanticSearch Boolean @default(true) - paragraphRefactor Boolean @default(true) - memoryEcho Boolean @default(true) - memoryEchoFrequency String @default("daily") - aiProvider String @default("auto") - preferredLanguage String @default("auto") - fontSize String @default("medium") - demoMode Boolean @default(false) - showRecentNotes Boolean @default(true) - notesViewMode String @default("masonry") - emailNotifications Boolean @default(false) - desktopNotifications Boolean @default(false) - anonymousAnalytics Boolean @default(false) + userId String @id + titleSuggestions Boolean @default(true) + semanticSearch Boolean @default(true) + paragraphRefactor Boolean @default(true) + memoryEcho Boolean @default(true) + memoryEchoFrequency String @default("daily") + aiProvider String @default("auto") + preferredLanguage String @default("auto") + fontSize String @default("medium") + demoMode Boolean @default(false) + showRecentNotes Boolean @default(true) + notesViewMode String @default("masonry") + emailNotifications Boolean @default(false) + desktopNotifications Boolean @default(false) + anonymousAnalytics Boolean @default(false) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@index([memoryEcho]) + @@index([aiProvider]) + @@index([memoryEchoFrequency]) + @@index([preferredLanguage]) }