fix: sync MCP schema exactly with memento-note (full copy)
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 16s

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 <noreply@anthropic.com>
This commit is contained in:
2026-04-26 15:02:15 +02:00
parent 3951b12d2e
commit 4b6f0f9526

View File

@@ -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 { generator client {
provider = "prisma-client-js" provider = "prisma-client-js"
output = "../node_modules/.prisma/client" output = "../node_modules/.prisma/client"
@@ -9,6 +15,68 @@ datasource db {
url = env("DATABASE_URL") url = env("DATABASE_URL")
} }
// ── Core models (used by MCP tools) ─────────────────────────────────────────
model User {
id String @id @default(cuid())
name String?
email String @unique
emailVerified DateTime?
password String?
role String @default("USER")
image String?
theme String @default("light")
cardSizeMode String @default("variable")
resetToken String? @unique
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 { model Note {
id String @id @default(cuid()) id String @id @default(cuid())
title String? title String?
@@ -42,7 +110,22 @@ model Note {
language String? language String?
languageConfidence Float? languageConfidence Float?
lastAiAnalysis DateTime? 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? noteEmbedding NoteEmbedding?
@@index([isPinned])
@@index([isArchived])
@@index([trashedAt])
@@index([order])
@@index([reminder])
@@index([userId])
@@index([userId, notebookId])
} }
model NoteEmbedding { model NoteEmbedding {
@@ -55,49 +138,28 @@ model NoteEmbedding {
@@index([noteId]) @@index([noteId])
} }
model Notebook { model NoteShare {
id String @id @default(cuid()) id String @id @default(cuid())
name String noteId String
icon String?
color String?
order Int
userId String userId String
sharedBy String
status String @default("pending")
permission String @default("view")
notifiedAt DateTime?
respondedAt DateTime?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
notes Note[] sharer User @relation("SentShares", fields: [sharedBy], references: [id], onDelete: Cascade)
labels Label[] user User @relation("ReceivedShares", fields: [userId], references: [id], onDelete: Cascade)
} note Note @relation(fields: [noteId], references: [id], onDelete: Cascade)
model Label { @@unique([noteId, userId])
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]) @@index([userId])
@@index([status])
@@index([sharedBy])
} }
model User { // ── Supporting models (used for auth, AI features, config) ──────────────────
id String @id @default(cuid())
name String?
email String @unique
emailVerified DateTime?
password String?
role String @default("USER")
image String?
theme String @default("light")
cardSizeMode String @default("variable")
resetToken String? @unique
resetTokenExpiry DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Account { model Account {
userId String userId String
@@ -113,6 +175,7 @@ model Account {
session_state String? session_state String?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([provider, providerAccountId]) @@id([provider, providerAccountId])
} }
@@ -123,6 +186,7 @@ model Session {
expires DateTime expires DateTime
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
} }
model VerificationToken { model VerificationToken {
@@ -133,21 +197,6 @@ model VerificationToken {
@@id([identifier, token]) @@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 { model SystemConfig {
key String @id key String @id
value String value String
@@ -163,6 +212,12 @@ model AiFeedback {
correctedContent String? correctedContent String?
metadata 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 { model MemoryEchoInsight {
@@ -176,8 +231,13 @@ model MemoryEchoInsight {
viewed Boolean @default(false) viewed Boolean @default(false)
feedback String? feedback String?
dismissed Boolean @default(false) 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]) @@unique([userId, insightDate])
@@index([userId, insightDate])
@@index([userId, dismissed])
} }
model UserAISettings { model UserAISettings {
@@ -196,4 +256,10 @@ model UserAISettings {
emailNotifications Boolean @default(false) emailNotifications Boolean @default(false)
desktopNotifications Boolean @default(false) desktopNotifications Boolean @default(false)
anonymousAnalytics Boolean @default(false) anonymousAnalytics Boolean @default(false)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([memoryEcho])
@@index([aiProvider])
@@index([memoryEchoFrequency])
@@index([preferredLanguage])
} }