// WF-P8 S02-N (Modal Notiz erstellen) — project-scoped notes with an explicit // visibility gate. // // AD-21: own schema file; `tenantId` / `autorUserId` are bare String scalars. // // Why a typed table and not `Activity`: the activity stream is an append-only, // per-entity timeline with a flat `summaryText` and no reader gate. S02-N // requires an editable body AND a visibility choice ("Alle mit Projektzugriff" // / "Nur Innendienst" / "Nur ich"), which the timeline cannot express. Creating // a note still appends an `Activity` entry via `logActivity` (AGENTS DoD #14). /// Who may read a note. `nur_ich` is author-only, `innendienst` is gated by the /// `projects.notes.read_internal` permission, `alle` follows normal project access. enum ProjektNotizSichtbarkeit { alle innendienst nur_ich } model ProjektNotiz { id String @id @default(cuid()) tenantId String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt projektId String autorUserId String? inhalt String sichtbarkeit ProjektNotizSichtbarkeit @default(alle) isDemoData Boolean @default(false) archivedAt DateTime? @@index([tenantId, projektId, createdAt(sort: Desc)]) @@index([tenantId, autorUserId]) }