Files
dataroom/prisma/schema/annotation.prisma
zeekayandHanzo Dev fa7c528ae4 feat(db): migrate Prisma datasource postgres -> sqlite (native, file-backed)
Drops the shared sql-0 postgres dependency in favor of an embedded SQLite
file (DATABASE_URL=file:/data/<db>), WAL-replicated to SeaweedFS by the
operator persistence sidecar — same pattern as esign (Documenso).

Schema changes for the sqlite connector:
- datasource provider postgresql -> sqlite; drop directUrl/shadowDatabaseUrl
- 18 enums -> String (values preserved as string defaults)
- scalar-list fields (String[]/Int[]) -> Json @default("[]") (arrays
  round-trip through Prisma Json at runtime; next.config ignoreBuildErrors
  keeps the type-only churn out of the build)
- strip pg-native @db.* attributes (@db.Text/@db.Timestamp)
- startup: prisma migrate deploy -> prisma db push (pg migration history is
  postgres-specific; db push reconciles the sqlite schema idempotently)

CI: amd64-only (DOKS has no arm64); deploy:false — rollout is operator-managed
via the universe Service CR, never `kubectl set image`.

Verified: `prisma validate` + `prisma db push` materialize all 62 tables on a
fresh sqlite file. Source DB is empty (0 app rows), so cutover is data-safe.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-05 00:33:13 -07:00

34 lines
1.3 KiB
Plaintext

model DocumentAnnotation {
id String @id @default(cuid())
title String
content Json // Rich text content stored as JSON (Tiptap/ProseMirror format)
pages Json @default("[]")// Array of page numbers this annotation applies to
documentId String
document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
teamId String
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
createdById String
createdBy User @relation(fields: [createdById], references: [id], onDelete: Cascade)
isVisible Boolean @default(true) // Allow admin to hide/show annotations
images AnnotationImage[] // Images attached to this annotation
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([documentId])
@@index([teamId])
@@index([createdById])
}
model AnnotationImage {
id String @id @default(cuid())
filename String
url String
size Int?
mimeType String?
annotationId String
annotation DocumentAnnotation @relation(fields: [annotationId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
@@index([annotationId])
}