Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions prisma/migrations/20260621135734_add_case_model/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- CreateTable "cases"
CREATE TABLE "cases" (
"id" TEXT NOT NULL PRIMARY KEY,
"title" TEXT NOT NULL,
"ownerId" TEXT NOT NULL,
"status" TEXT NOT NULL DEFAULT 'open',
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL
);

-- CreateIndex
CREATE INDEX "cases_ownerId_idx" ON "cases"("ownerId");

-- AddForeignKey for cases
ALTER TABLE "cases" ADD CONSTRAINT "cases_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey for investigation_notes
ALTER TABLE "investigation_notes" ADD CONSTRAINT "investigation_notes_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "cases"("id") ON DELETE CASCADE ON UPDATE CASCADE;
3 changes: 3 additions & 0 deletions prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added to your version control system (i.e. Git)
provider = "postgresql"
23 changes: 22 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ model User {
watchlist Watchlist[]
notificationPreferences NotificationPreference[]
auditLogs AuditLog[]
cases Case[]

@@map("users")
}
Expand Down Expand Up @@ -116,6 +117,25 @@ model GovernanceEvent {
@@map("governance_events")
}

// ---------------------------------------------------------------------------
// Case Management – independent investigation tracking
// ---------------------------------------------------------------------------

model Case {
id String @id @default(cuid())
title String
ownerId String
status String @default("open") // "open", "in_progress", "closed", "on_hold"
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

owner User @relation(fields: [ownerId], references: [id])
investigationNotes InvestigationNote[]

@@index([ownerId])
@@map("cases")
}

// ---------------------------------------------------------------------------
// Investigation Notes – issue #127
// ---------------------------------------------------------------------------
Expand All @@ -133,7 +153,8 @@ model InvestigationNote {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

auditEntries NoteAuditLog[]
case Case @relation(fields: [caseId], references: [id], onDelete: Cascade)
auditEntries NoteAuditLog[]

@@index([caseId])
@@map("investigation_notes")
Expand Down
Loading