generator client { provider = "prisma-client-js" output = "../node_modules/.prisma/client-auth" } datasource db { provider = "postgresql" url = env("DATABASE_URL_AUTH") } model User { id Int @id @default(autoincrement()) email String @unique name String passwordHash String @map("password_hash") isAdmin Boolean @default(false) @map("is_admin") hasWriteAccess Boolean @default(false) @map("has_write_access") emailVerified Boolean @default(false) @map("email_verified") emailConfirmationToken String? @unique @map("email_confirmation_token") emailConfirmationTokenExpiry DateTime? @map("email_confirmation_token_expiry") passwordResetToken String? @unique @map("password_reset_token") passwordResetTokenExpiry DateTime? @map("password_reset_token_expiry") isActive Boolean @default(true) @map("is_active") createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") pendingIdentifications PendingIdentification[] pendingPhotos PendingPhoto[] inappropriatePhotoReports InappropriatePhotoReport[] pendingLinkages PendingLinkage[] photoFavorites PhotoFavorite[] @@map("users") } model PendingIdentification { id Int @id @default(autoincrement()) faceId Int @map("face_id") userId Int @map("user_id") firstName String @map("first_name") lastName String @map("last_name") middleName String? @map("middle_name") maidenName String? @map("maiden_name") dateOfBirth DateTime? @map("date_of_birth") @db.Date status String @default("pending") // pending, approved, rejected createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") user User @relation(fields: [userId], references: [id], onDelete: Cascade) // Note: faceId references faces in the punimtag database, but we can't use a foreign key // across databases. We'll validate the face exists in application code. @@index([faceId]) @@index([userId]) @@index([status]) @@map("pending_identifications") } model PendingPhoto { id Int @id @default(autoincrement()) userId Int @map("user_id") filename String originalFilename String @map("original_filename") filePath String @map("file_path") fileSize Int @map("file_size") mimeType String @map("mime_type") status String @default("pending") // pending, approved, rejected submittedAt DateTime @default(now()) @map("submitted_at") reviewedAt DateTime? @map("reviewed_at") reviewedBy Int? @map("reviewed_by") // Admin user ID who reviewed rejectionReason String? @map("rejection_reason") user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@index([userId]) @@index([status]) @@index([submittedAt]) @@map("pending_photos") } model InappropriatePhotoReport { id Int @id @default(autoincrement()) photoId Int @map("photo_id") userId Int @map("user_id") status String @default("pending") // pending, reviewed, dismissed reportedAt DateTime @default(now()) @map("reported_at") reviewedAt DateTime? @map("reviewed_at") reviewedBy Int? @map("reviewed_by") // Admin user ID who reviewed reviewNotes String? @map("review_notes") reportComment String? @map("report_comment") user User @relation(fields: [userId], references: [id], onDelete: Cascade) // Note: photoId references photos in the punimtag database, but we can't use a foreign key // across databases. We'll validate the photo exists in application code. @@unique([photoId, userId], name: "uq_photo_user_report") // Prevent duplicate reports from same user @@index([photoId]) @@index([userId]) @@index([status]) @@index([reportedAt]) @@map("inappropriate_photo_reports") } model PendingLinkage { id Int @id @default(autoincrement()) photoId Int @map("photo_id") tagId Int? @map("tag_id") tagName String? @map("tag_name") userId Int @map("user_id") status String @default("pending") notes String? @map("notes") createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@index([photoId]) @@index([tagId]) @@index([userId]) @@index([status]) @@map("pending_linkages") } model PhotoFavorite { id Int @id @default(autoincrement()) photoId Int @map("photo_id") userId Int @map("user_id") favoritedAt DateTime @default(now()) @map("favorited_at") user User @relation(fields: [userId], references: [id], onDelete: Cascade) // Note: photoId references photos in the punimtag database, but we can't use a foreign key // across databases. We'll validate the photo exists in application code. @@unique([photoId, userId], name: "uq_photo_user_favorite") @@index([photoId]) @@index([userId]) @@index([favoritedAt]) @@map("photo_favorites") }