2025-11-12 21:56:11 +01:00
|
|
|
// Prisma schema for spotlight.cam
|
|
|
|
|
// Database: PostgreSQL 15
|
|
|
|
|
|
|
|
|
|
generator client {
|
2025-11-13 16:11:04 +01:00
|
|
|
provider = "prisma-client-js"
|
|
|
|
|
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
|
2025-11-12 21:56:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datasource db {
|
|
|
|
|
provider = "postgresql"
|
|
|
|
|
url = env("DATABASE_URL")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Users table
|
|
|
|
|
model User {
|
feat: add email verification, password reset, and WSDC integration (Phase 1.5)
Backend features:
- AWS SES email service with HTML templates
- Email verification with dual method (link + 6-digit PIN code)
- Password reset workflow with secure tokens
- WSDC API proxy for dancer lookup and auto-fill registration
- Extended User model with verification and WSDC fields
- Email verification middleware for protected routes
Frontend features:
- Two-step registration with WSDC ID lookup
- Password strength indicator component
- Email verification page with code input
- Password reset flow (request + reset pages)
- Verification banner for unverified users
- Updated authentication context and API service
Testing:
- 65 unit tests with 100% coverage of new features
- Tests for auth utils, email service, WSDC controller, and middleware
- Integration tests for full authentication flows
- Comprehensive mocking of AWS SES and external APIs
Database:
- Migration: add WSDC fields (firstName, lastName, wsdcId)
- Migration: add email verification fields (token, code, expiry)
- Migration: add password reset fields (token, expiry)
Documentation:
- Complete Phase 1.5 documentation
- Test suite documentation and best practices
- Updated session context with new features
2025-11-13 15:47:54 +01:00
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
username String @unique @db.VarChar(50)
|
|
|
|
|
email String @unique @db.VarChar(255)
|
|
|
|
|
passwordHash String @map("password_hash") @db.VarChar(255)
|
|
|
|
|
|
|
|
|
|
// WSDC Integration (Phase 1.5)
|
|
|
|
|
firstName String? @map("first_name") @db.VarChar(100)
|
|
|
|
|
lastName String? @map("last_name") @db.VarChar(100)
|
|
|
|
|
wsdcId String? @unique @map("wsdc_id") @db.VarChar(20)
|
|
|
|
|
|
2025-11-13 20:47:57 +01:00
|
|
|
// Social Media Links
|
|
|
|
|
youtubeUrl String? @map("youtube_url") @db.VarChar(255)
|
|
|
|
|
instagramUrl String? @map("instagram_url") @db.VarChar(255)
|
|
|
|
|
facebookUrl String? @map("facebook_url") @db.VarChar(255)
|
|
|
|
|
tiktokUrl String? @map("tiktok_url") @db.VarChar(255)
|
|
|
|
|
|
2025-11-13 20:57:43 +01:00
|
|
|
// Location
|
|
|
|
|
country String? @db.VarChar(100)
|
|
|
|
|
city String? @db.VarChar(100)
|
|
|
|
|
|
feat: add email verification, password reset, and WSDC integration (Phase 1.5)
Backend features:
- AWS SES email service with HTML templates
- Email verification with dual method (link + 6-digit PIN code)
- Password reset workflow with secure tokens
- WSDC API proxy for dancer lookup and auto-fill registration
- Extended User model with verification and WSDC fields
- Email verification middleware for protected routes
Frontend features:
- Two-step registration with WSDC ID lookup
- Password strength indicator component
- Email verification page with code input
- Password reset flow (request + reset pages)
- Verification banner for unverified users
- Updated authentication context and API service
Testing:
- 65 unit tests with 100% coverage of new features
- Tests for auth utils, email service, WSDC controller, and middleware
- Integration tests for full authentication flows
- Comprehensive mocking of AWS SES and external APIs
Database:
- Migration: add WSDC fields (firstName, lastName, wsdcId)
- Migration: add email verification fields (token, code, expiry)
- Migration: add password reset fields (token, expiry)
Documentation:
- Complete Phase 1.5 documentation
- Test suite documentation and best practices
- Updated session context with new features
2025-11-13 15:47:54 +01:00
|
|
|
// Email Verification (Phase 1.5)
|
|
|
|
|
emailVerified Boolean @default(false) @map("email_verified")
|
|
|
|
|
verificationToken String? @unique @map("verification_token") @db.VarChar(255)
|
|
|
|
|
verificationCode String? @map("verification_code") @db.VarChar(6)
|
|
|
|
|
verificationTokenExpiry DateTime? @map("verification_token_expiry")
|
|
|
|
|
|
|
|
|
|
// Password Reset (Phase 1.5)
|
|
|
|
|
resetToken String? @unique @map("reset_token") @db.VarChar(255)
|
|
|
|
|
resetTokenExpiry DateTime? @map("reset_token_expiry")
|
|
|
|
|
|
|
|
|
|
avatar String? @db.VarChar(255)
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
2025-11-12 21:56:11 +01:00
|
|
|
|
|
|
|
|
// Relations
|
feat: add email verification, password reset, and WSDC integration (Phase 1.5)
Backend features:
- AWS SES email service with HTML templates
- Email verification with dual method (link + 6-digit PIN code)
- Password reset workflow with secure tokens
- WSDC API proxy for dancer lookup and auto-fill registration
- Extended User model with verification and WSDC fields
- Email verification middleware for protected routes
Frontend features:
- Two-step registration with WSDC ID lookup
- Password strength indicator component
- Email verification page with code input
- Password reset flow (request + reset pages)
- Verification banner for unverified users
- Updated authentication context and API service
Testing:
- 65 unit tests with 100% coverage of new features
- Tests for auth utils, email service, WSDC controller, and middleware
- Integration tests for full authentication flows
- Comprehensive mocking of AWS SES and external APIs
Database:
- Migration: add WSDC fields (firstName, lastName, wsdcId)
- Migration: add email verification fields (token, code, expiry)
- Migration: add password reset fields (token, expiry)
Documentation:
- Complete Phase 1.5 documentation
- Test suite documentation and best practices
- Updated session context with new features
2025-11-13 15:47:54 +01:00
|
|
|
messages Message[]
|
|
|
|
|
matchesAsUser1 Match[] @relation("MatchUser1")
|
|
|
|
|
matchesAsUser2 Match[] @relation("MatchUser2")
|
|
|
|
|
ratingsGiven Rating[] @relation("RaterRatings")
|
|
|
|
|
ratingsReceived Rating[] @relation("RatedRatings")
|
2025-11-12 21:56:11 +01:00
|
|
|
|
|
|
|
|
@@map("users")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Events table (dance events from worldsdc.com)
|
|
|
|
|
model Event {
|
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
name String @db.VarChar(255)
|
|
|
|
|
location String @db.VarChar(255)
|
|
|
|
|
startDate DateTime @map("start_date") @db.Date
|
|
|
|
|
endDate DateTime @map("end_date") @db.Date
|
|
|
|
|
worldsdcId String? @unique @map("worldsdc_id") @db.VarChar(100)
|
|
|
|
|
participantsCount Int @default(0) @map("participants_count")
|
|
|
|
|
description String? @db.Text
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
|
|
|
|
|
// Relations
|
|
|
|
|
chatRooms ChatRoom[]
|
|
|
|
|
matches Match[]
|
|
|
|
|
|
|
|
|
|
@@map("events")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Chat rooms (event chat and private 1:1 chat)
|
|
|
|
|
model ChatRoom {
|
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
eventId Int? @map("event_id")
|
|
|
|
|
type String @db.VarChar(20) // 'event' or 'private'
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
|
|
|
|
|
// Relations
|
|
|
|
|
event Event? @relation(fields: [eventId], references: [id])
|
|
|
|
|
messages Message[]
|
|
|
|
|
matches Match[]
|
|
|
|
|
|
|
|
|
|
@@map("chat_rooms")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Messages (text messages and video links)
|
|
|
|
|
model Message {
|
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
roomId Int @map("room_id")
|
|
|
|
|
userId Int @map("user_id")
|
|
|
|
|
content String @db.Text
|
|
|
|
|
type String @db.VarChar(20) // 'text', 'link', 'video'
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
|
|
|
|
|
// Relations
|
|
|
|
|
room ChatRoom @relation(fields: [roomId], references: [id], onDelete: Cascade)
|
|
|
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
|
|
|
|
|
|
@@index([roomId])
|
|
|
|
|
@@index([createdAt])
|
|
|
|
|
@@map("messages")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Matches (pairs of users for collaboration)
|
|
|
|
|
model Match {
|
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
user1Id Int @map("user1_id")
|
|
|
|
|
user2Id Int @map("user2_id")
|
|
|
|
|
eventId Int @map("event_id")
|
|
|
|
|
roomId Int? @map("room_id")
|
|
|
|
|
status String @default("pending") @db.VarChar(20) // 'pending', 'accepted', 'completed'
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
|
|
|
|
|
// Relations
|
|
|
|
|
user1 User @relation("MatchUser1", fields: [user1Id], references: [id])
|
|
|
|
|
user2 User @relation("MatchUser2", fields: [user2Id], references: [id])
|
|
|
|
|
event Event @relation(fields: [eventId], references: [id])
|
|
|
|
|
room ChatRoom? @relation(fields: [roomId], references: [id])
|
|
|
|
|
ratings Rating[]
|
|
|
|
|
|
|
|
|
|
@@unique([user1Id, user2Id, eventId])
|
|
|
|
|
@@index([user1Id])
|
|
|
|
|
@@index([user2Id])
|
|
|
|
|
@@index([eventId])
|
|
|
|
|
@@map("matches")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ratings (user ratings after collaboration)
|
|
|
|
|
model Rating {
|
|
|
|
|
id Int @id @default(autoincrement())
|
|
|
|
|
matchId Int @map("match_id")
|
|
|
|
|
raterId Int @map("rater_id")
|
|
|
|
|
ratedId Int @map("rated_id")
|
|
|
|
|
score Int // 1-5
|
|
|
|
|
comment String? @db.Text
|
|
|
|
|
wouldCollaborateAgain Boolean @default(false) @map("would_collaborate_again")
|
|
|
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
|
|
|
|
|
|
// Relations
|
|
|
|
|
match Match @relation(fields: [matchId], references: [id])
|
|
|
|
|
rater User @relation("RaterRatings", fields: [raterId], references: [id])
|
|
|
|
|
rated User @relation("RatedRatings", fields: [ratedId], references: [id])
|
|
|
|
|
|
|
|
|
|
@@unique([matchId, raterId, ratedId])
|
|
|
|
|
@@index([ratedId])
|
|
|
|
|
@@map("ratings")
|
|
|
|
|
}
|