Files
towercontrol/prisma/schema.prisma
Julien Froidefond 7952459b42 feat(Tags): implement user-specific tag management and enhance related services
- Added ownerId field to Tag model to associate tags with users.
- Updated tagsService methods to enforce user ownership in tag operations.
- Enhanced API routes to include user authentication and ownership checks for tag retrieval and management.
- Modified seeding script to assign tags to the first user found in the database.
- Updated various components and services to ensure user-specific tag handling throughout the application.
2025-10-11 15:03:59 +02:00

161 lines
4.9 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
email String @unique
name String?
firstName String?
lastName String?
avatar String? // URL de l'avatar
role String @default("user") // user, admin, etc.
isActive Boolean @default(true)
lastLoginAt DateTime?
password String // Hashé avec bcrypt
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
preferences UserPreferences?
notes Note[]
dailyCheckboxes DailyCheckbox[]
tasks Task[] @relation("TaskOwner")
tags Tag[] @relation("TagOwner")
@@map("users")
}
model Task {
id String @id @default(cuid())
title String
description String?
status String @default("todo")
priority String @default("medium")
source String
sourceId String?
dueDate DateTime?
completedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
jiraProject String?
jiraKey String?
assignee String? // Legacy field - keep for Jira/TFS compatibility
ownerId String // Required - chaque tâche appartient à un user
owner User @relation("TaskOwner", fields: [ownerId], references: [id], onDelete: Cascade)
jiraType String?
tfsProject String?
tfsPullRequestId Int?
tfsRepository String?
tfsSourceBranch String?
tfsTargetBranch String?
primaryTagId String?
primaryTag Tag? @relation("PrimaryTag", fields: [primaryTagId], references: [id])
dailyCheckboxes DailyCheckbox[]
taskTags TaskTag[]
notes Note[] // Notes associées à cette tâche
@@unique([source, sourceId])
@@map("tasks")
}
model Tag {
id String @id @default(cuid())
name String
color String @default("#6b7280")
isPinned Boolean @default(false)
ownerId String // Chaque tag appartient à un utilisateur
owner User @relation("TagOwner", fields: [ownerId], references: [id], onDelete: Cascade)
taskTags TaskTag[]
primaryTasks Task[] @relation("PrimaryTag")
noteTags NoteTag[]
@@unique([name, ownerId]) // Un nom de tag unique par utilisateur
@@map("tags")
}
model TaskTag {
taskId String
tagId String
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
task Task @relation(fields: [taskId], references: [id], onDelete: Cascade)
@@id([taskId, tagId])
@@map("task_tags")
}
model SyncLog {
id String @id @default(cuid())
source String
status String
message String?
tasksSync Int @default(0)
createdAt DateTime @default(now())
@@map("sync_logs")
}
model DailyCheckbox {
id String @id @default(cuid())
date DateTime
text String
isChecked Boolean @default(false)
type String @default("task")
order Int @default(0)
taskId String?
userId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
task Task? @relation(fields: [taskId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([date])
@@index([userId])
@@map("daily_checkboxes")
}
model UserPreferences {
id String @id @default(cuid())
userId String @unique
kanbanFilters Json?
viewPreferences Json?
columnVisibility Json?
jiraConfig Json?
jiraAutoSync Boolean @default(false)
jiraSyncInterval String @default("daily")
tfsConfig Json?
tfsAutoSync Boolean @default(false)
tfsSyncInterval String @default("daily")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map("user_preferences")
}
model Note {
id String @id @default(cuid())
title String
content String // Markdown content
userId String
taskId String? // Tâche associée à la note
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
task Task? @relation(fields: [taskId], references: [id])
noteTags NoteTag[]
}
model NoteTag {
noteId String
tagId String
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
note Note @relation(fields: [noteId], references: [id], onDelete: Cascade)
@@id([noteId, tagId])
@@map("note_tags")
}