initial commit
This commit is contained in:
132
src/backend/prisma/schema.prisma
Normal file
132
src/backend/prisma/schema.prisma
Normal file
@@ -0,0 +1,132 @@
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
model Company {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
vatNumber String? @unique
|
||||
email String?
|
||||
phone String?
|
||||
address String?
|
||||
city String?
|
||||
isActive Boolean @default(true)
|
||||
notes String?
|
||||
externalId String?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
workers Worker[]
|
||||
sites Site[]
|
||||
notifications Notification[]
|
||||
}
|
||||
|
||||
model Site {
|
||||
id Int @id @default(autoincrement())
|
||||
name String // e.g. "Sede Principale", "Cantiere A"
|
||||
address String?
|
||||
city String?
|
||||
companyId Int
|
||||
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
|
||||
|
||||
isActive Boolean @default(true)
|
||||
|
||||
workers Worker[]
|
||||
}
|
||||
|
||||
model Worker {
|
||||
id Int @id @default(autoincrement())
|
||||
firstName String
|
||||
lastName String
|
||||
taxCode String? @unique // Codice Fiscale
|
||||
jobTitle String? // Mansione
|
||||
email String?
|
||||
phone String?
|
||||
|
||||
companyId Int
|
||||
company Company @relation(fields: [companyId], references: [id])
|
||||
|
||||
siteId Int?
|
||||
site Site? @relation(fields: [siteId], references: [id])
|
||||
|
||||
isActive Boolean @default(true)
|
||||
hiringDate DateTime?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
events TrainingEvent[]
|
||||
}
|
||||
|
||||
model Course {
|
||||
id Int @id @default(autoincrement())
|
||||
title String
|
||||
code String @default("TEMP") // Temporaneo default per migrazione, poi rimuovo o rendo unique
|
||||
description String?
|
||||
validityYears Int // Durata validita in anni (es. 5)
|
||||
hasPostExpiryReminder Boolean @default(false)
|
||||
isSafety Boolean @default(true)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
events TrainingEvent[]
|
||||
}
|
||||
|
||||
model TrainingEvent {
|
||||
id Int @id @default(autoincrement())
|
||||
|
||||
workerId Int
|
||||
worker Worker @relation(fields: [workerId], references: [id], onDelete: Cascade)
|
||||
|
||||
courseId Int
|
||||
course Course @relation(fields: [courseId], references: [id])
|
||||
|
||||
eventDate DateTime // Data del corso
|
||||
expiryDate DateTime? // Data scadenza calcolata
|
||||
|
||||
provider String? // Ente formatore
|
||||
certificateUrl String? // Link al file PDF
|
||||
|
||||
status String @default("VALID") // VALID, EXPIRING, EXPIRED
|
||||
|
||||
notes String?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Notification {
|
||||
id Int @id @default(autoincrement())
|
||||
companyId Int
|
||||
company Company @relation(fields: [companyId], references: [id])
|
||||
|
||||
type String // 'EXPIRING_REMINDER', 'EXPIRED_ALERT'
|
||||
status String @default("PENDING") // PENDING, SENT, FAILED
|
||||
|
||||
subject String
|
||||
content String // HTML content or JSON data to render
|
||||
|
||||
sentAt DateTime?
|
||||
scheduledFor DateTime?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
email String @unique
|
||||
password String
|
||||
name String?
|
||||
role String @default("ADMIN") // ADMIN, USER
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
Reference in New Issue
Block a user