125 lines
3.3 KiB
Plaintext
125 lines
3.3 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
email String @unique
|
|
name String?
|
|
password String
|
|
sessions Session[]
|
|
sharedSessions SessionShare[]
|
|
sessionEvents SessionEvent[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
title String
|
|
collaborator String
|
|
date DateTime @default(now())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
items SwotItem[]
|
|
actions Action[]
|
|
shares SessionShare[]
|
|
events SessionEvent[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
enum SwotCategory {
|
|
STRENGTH
|
|
WEAKNESS
|
|
OPPORTUNITY
|
|
THREAT
|
|
}
|
|
|
|
model SwotItem {
|
|
id String @id @default(cuid())
|
|
content String
|
|
category SwotCategory
|
|
order Int @default(0)
|
|
sessionId String
|
|
session Session @relation(fields: [sessionId], references: [id], onDelete: Cascade)
|
|
actionLinks ActionLink[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([sessionId])
|
|
}
|
|
|
|
model Action {
|
|
id String @id @default(cuid())
|
|
title String
|
|
description String?
|
|
priority Int @default(0)
|
|
status String @default("todo")
|
|
dueDate DateTime?
|
|
sessionId String
|
|
session Session @relation(fields: [sessionId], references: [id], onDelete: Cascade)
|
|
links ActionLink[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([sessionId])
|
|
}
|
|
|
|
model ActionLink {
|
|
id String @id @default(cuid())
|
|
actionId String
|
|
action Action @relation(fields: [actionId], references: [id], onDelete: Cascade)
|
|
swotItemId String
|
|
swotItem SwotItem @relation(fields: [swotItemId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([actionId, swotItemId])
|
|
@@index([actionId])
|
|
@@index([swotItemId])
|
|
}
|
|
|
|
// ============================================
|
|
// Collaboration & Real-time
|
|
// ============================================
|
|
|
|
enum ShareRole {
|
|
VIEWER
|
|
EDITOR
|
|
}
|
|
|
|
model SessionShare {
|
|
id String @id @default(cuid())
|
|
sessionId String
|
|
session Session @relation(fields: [sessionId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
role ShareRole @default(EDITOR)
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([sessionId, userId])
|
|
@@index([sessionId])
|
|
@@index([userId])
|
|
}
|
|
|
|
model SessionEvent {
|
|
id String @id @default(cuid())
|
|
sessionId String
|
|
session Session @relation(fields: [sessionId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
type String // ITEM_CREATED, ITEM_UPDATED, ITEM_DELETED, ACTION_CREATED, etc.
|
|
payload String // JSON payload
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([sessionId, createdAt])
|
|
}
|