Add personal/team note visibility and edit history.
Notes can be marked personal or team, with revision snapshots and restore from the notes UI.
This commit is contained in:
@@ -162,6 +162,7 @@ model Organization {
|
||||
deals Deal[]
|
||||
activities Activity[]
|
||||
notes Note[]
|
||||
noteRevisions NoteRevision[]
|
||||
customFields CustomFieldDefinition[]
|
||||
products Product[]
|
||||
notifications Notification[]
|
||||
@@ -231,6 +232,7 @@ model User {
|
||||
activities Activity[] @relation("ActivityAssignee")
|
||||
createdActivities Activity[] @relation("ActivityCreator")
|
||||
notes Note[] @relation("NoteAuthor")
|
||||
noteRevisions NoteRevision[] @relation("NoteRevisionEditor")
|
||||
noteAttachments NoteAttachment[] @relation("NoteAttachmentUploader")
|
||||
notifications Notification[]
|
||||
salesGoals SalesGoal[] @relation("SalesGoalUser")
|
||||
@@ -591,14 +593,18 @@ model Note {
|
||||
activity Activity? @relation(fields: [activityId], references: [id], onDelete: SetNull)
|
||||
authorId String?
|
||||
author User? @relation("NoteAuthor", fields: [authorId], references: [id], onDelete: SetNull)
|
||||
/// team = قابلمشاهده برای تیم/سازمان در محدوده پرونده | personal = فقط نویسنده
|
||||
visibility String @default("team")
|
||||
attachments NoteAttachment[]
|
||||
aiSuggestion NoteAiSuggestion?
|
||||
revisions NoteRevision[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([organizationId, pinned, updatedAt])
|
||||
@@index([organizationId, noteType, updatedAt])
|
||||
@@index([organizationId, reminderAt])
|
||||
@@index([organizationId, visibility])
|
||||
@@index([personId])
|
||||
@@index([companyId])
|
||||
@@index([dealId])
|
||||
@@ -606,6 +612,28 @@ model Note {
|
||||
@@index([authorId])
|
||||
}
|
||||
|
||||
/// اسنپشات متن قبل از هر ویرایش معنادار یادداشت
|
||||
model NoteRevision {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
noteId String
|
||||
note Note @relation(fields: [noteId], references: [id], onDelete: Cascade)
|
||||
editorId String?
|
||||
editor User? @relation("NoteRevisionEditor", fields: [editorId], references: [id], onDelete: SetNull)
|
||||
title String?
|
||||
body String
|
||||
noteType String
|
||||
visibility String @default("team")
|
||||
tags String[] @default([])
|
||||
checklist Json?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([noteId, createdAt])
|
||||
@@index([organizationId])
|
||||
@@index([editorId])
|
||||
}
|
||||
|
||||
model NoteAttachment {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
|
||||
Reference in New Issue
Block a user