Add Smart Notes AI analysis and Mento Memory with user approval.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "NoteAiSuggestionStatus" AS ENUM ('pending', 'applied', 'dismissed', 'failed');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "MemorySourceType" AS ENUM ('note', 'manual');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "NoteAiSuggestion" (
|
||||
"id" TEXT NOT NULL,
|
||||
"organizationId" TEXT NOT NULL,
|
||||
"noteId" TEXT NOT NULL,
|
||||
"status" "NoteAiSuggestionStatus" NOT NULL DEFAULT 'pending',
|
||||
"payload" JSONB,
|
||||
"errorMessage" TEXT,
|
||||
"analyzedAt" TIMESTAMP(3),
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "NoteAiSuggestion_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "MemoryItem" (
|
||||
"id" TEXT NOT NULL,
|
||||
"organizationId" TEXT NOT NULL,
|
||||
"personId" TEXT NOT NULL,
|
||||
"content" TEXT NOT NULL,
|
||||
"sourceType" "MemorySourceType" NOT NULL DEFAULT 'manual',
|
||||
"sourceId" TEXT,
|
||||
"confirmedById" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "MemoryItem_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "NoteAiSuggestion_noteId_key" ON "NoteAiSuggestion"("noteId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "NoteAiSuggestion_organizationId_status_idx" ON "NoteAiSuggestion"("organizationId", "status");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "MemoryItem_organizationId_personId_updatedAt_idx" ON "MemoryItem"("organizationId", "personId", "updatedAt");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "MemoryItem_personId_idx" ON "MemoryItem"("personId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "MemoryItem_confirmedById_idx" ON "MemoryItem"("confirmedById");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "NoteAiSuggestion" ADD CONSTRAINT "NoteAiSuggestion_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "NoteAiSuggestion" ADD CONSTRAINT "NoteAiSuggestion_noteId_fkey" FOREIGN KEY ("noteId") REFERENCES "Note"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "MemoryItem" ADD CONSTRAINT "MemoryItem_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "MemoryItem" ADD CONSTRAINT "MemoryItem_personId_fkey" FOREIGN KEY ("personId") REFERENCES "Person"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "MemoryItem" ADD CONSTRAINT "MemoryItem_confirmedById_fkey" FOREIGN KEY ("confirmedById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -103,6 +103,18 @@ enum AutomationAction {
|
||||
add_loyalty_points
|
||||
}
|
||||
|
||||
enum NoteAiSuggestionStatus {
|
||||
pending
|
||||
applied
|
||||
dismissed
|
||||
failed
|
||||
}
|
||||
|
||||
enum MemorySourceType {
|
||||
note
|
||||
manual
|
||||
}
|
||||
|
||||
model Organization {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
@@ -134,6 +146,8 @@ model Organization {
|
||||
projectCards ProjectCard[]
|
||||
loyaltyTiers LoyaltyTier[]
|
||||
automationRules AutomationRule[]
|
||||
memoryItems MemoryItem[]
|
||||
noteAiSuggestions NoteAiSuggestion[]
|
||||
}
|
||||
|
||||
model User {
|
||||
@@ -158,6 +172,7 @@ model User {
|
||||
assignedTickets Ticket[] @relation("TicketAssignee")
|
||||
reportedTickets Ticket[] @relation("TicketReporter")
|
||||
ticketMessages TicketMessage[] @relation("TicketMessageAuthor")
|
||||
confirmedMemories MemoryItem[] @relation("MemoryConfirmedBy")
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -223,6 +238,7 @@ model Person {
|
||||
owner User? @relation("PersonOwner", fields: [ownerId], references: [id], onDelete: SetNull)
|
||||
tickets Ticket[]
|
||||
projectCards ProjectCard[]
|
||||
memoryItems MemoryItem[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -359,6 +375,7 @@ model Note {
|
||||
authorId String?
|
||||
author User? @relation("NoteAuthor", fields: [authorId], references: [id], onDelete: SetNull)
|
||||
attachments NoteAttachment[]
|
||||
aiSuggestion NoteAiSuggestion?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -390,6 +407,41 @@ model NoteAttachment {
|
||||
@@index([uploadedById])
|
||||
}
|
||||
|
||||
model NoteAiSuggestion {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
noteId String @unique
|
||||
note Note @relation(fields: [noteId], references: [id], onDelete: Cascade)
|
||||
status NoteAiSuggestionStatus @default(pending)
|
||||
payload Json?
|
||||
errorMessage String?
|
||||
analyzedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([organizationId, status])
|
||||
}
|
||||
|
||||
model MemoryItem {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
personId String
|
||||
person Person @relation(fields: [personId], references: [id], onDelete: Cascade)
|
||||
content String
|
||||
sourceType MemorySourceType @default(manual)
|
||||
sourceId String?
|
||||
confirmedById String?
|
||||
confirmedBy User? @relation("MemoryConfirmedBy", fields: [confirmedById], references: [id], onDelete: SetNull)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([organizationId, personId, updatedAt])
|
||||
@@index([personId])
|
||||
@@index([confirmedById])
|
||||
}
|
||||
|
||||
model CustomFieldDefinition {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
|
||||
Reference in New Issue
Block a user