Files
recall/prisma/schema.prisma
Daniel Arroyo ff7223bfea feat: MVP-3 Sprint 4 - Co-usage, metrics, centrality, creation source, feature flags
- Add NoteCoUsage model and co-usage tracking when viewing notes
- Add creationSource field to notes (form/quick/import)
- Add dashboard metrics API (/api/metrics)
- Add centrality calculation (/api/centrality)
- Add feature flags system for toggling features
- Add multiline QuickAdd with smart paste type detection
- Add internal link suggestions while editing notes
- Add type inference for automatic note type detection
- Add comprehensive tests for type-inference and link-suggestions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 16:50:40 -03:00

81 lines
2.4 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model Note {
id String @id @default(cuid())
title String
content String
type String @default("note")
isFavorite Boolean @default(false)
isPinned Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
creationSource String @default("form") // 'form' | 'quick' | 'import'
tags NoteTag[]
backlinks Backlink[] @relation("BacklinkTarget")
outbound Backlink[] @relation("BacklinkSource")
usageEvents NoteUsage[]
coUsageFrom NoteCoUsage[] @relation("CoUsageFrom")
coUsageTo NoteCoUsage[] @relation("CoUsageTo")
}
model Tag {
id String @id @default(cuid())
name String @unique
notes NoteTag[]
}
model NoteTag {
noteId String
tagId String
note Note @relation(fields: [noteId], references: [id], onDelete: Cascade)
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
@@id([noteId, tagId])
}
model Backlink {
id String @id @default(cuid())
sourceNoteId String
targetNoteId String
sourceNote Note @relation("BacklinkSource", fields: [sourceNoteId], references: [id], onDelete: Cascade)
targetNote Note @relation("BacklinkTarget", fields: [targetNoteId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
@@unique([sourceNoteId, targetNoteId])
}
model NoteUsage {
id String @id @default(cuid())
noteId String
note Note @relation(fields: [noteId], references: [id], onDelete: Cascade)
eventType String // 'view' | 'search_click' | 'related_click' | 'link_click'
query String?
metadata String?
createdAt DateTime @default(now())
@@index([noteId, createdAt])
@@index([eventType, createdAt])
}
model NoteCoUsage {
id String @id @default(cuid())
fromNoteId String
fromNote Note @relation("CoUsageFrom", fields: [fromNoteId], references: [id], onDelete: Cascade)
toNoteId String
toNote Note @relation("CoUsageTo", fields: [toNoteId], references: [id], onDelete: Cascade)
weight Int @default(1) // times viewed together
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([fromNoteId, toNoteId])
@@index([fromNoteId])
@@index([toNoteId])
}