Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 102 additions & 98 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,21 @@ model mfa_challenges {
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info.
model mfa_factors {
id String @id @db.Uuid
user_id String @db.Uuid
friendly_name String?
factor_type factor_type
status factor_status
created_at DateTime @db.Timestamptz(6)
updated_at DateTime @db.Timestamptz(6)
secret String?
phone String?
last_challenged_at DateTime? @unique @db.Timestamptz(6)
web_authn_credential Json?
web_authn_aaguid String? @db.Uuid
mfa_challenges mfa_challenges[]
users auth_users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
id String @id @db.Uuid
user_id String @db.Uuid
friendly_name String?
factor_type factor_type
status factor_status
created_at DateTime @db.Timestamptz(6)
updated_at DateTime @db.Timestamptz(6)
secret String?
phone String?
last_challenged_at DateTime? @unique @db.Timestamptz(6)
web_authn_credential Json?
web_authn_aaguid String? @db.Uuid
last_webauthn_challenge_data Json?
mfa_challenges mfa_challenges[]
users auth_users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction)

@@unique([user_id, phone], map: "unique_phone_factor_per_user")
@@index([user_id, created_at], map: "factor_id_created_at_idx")
Expand All @@ -150,6 +151,7 @@ model oauth_authorizations {
created_at DateTime @default(now()) @db.Timestamptz(6)
expires_at DateTime @default(dbgenerated("(now() + '00:03:00'::interval)")) @db.Timestamptz(6)
approved_at DateTime? @db.Timestamptz(6)
nonce String?
oauth_clients oauth_clients @relation(fields: [client_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
users auth_users? @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction)

Expand Down Expand Up @@ -282,25 +284,29 @@ model schema_migrations {
@@schema("auth")
}

/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info.
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info.
model sessions {
id String @id @db.Uuid
user_id String @db.Uuid
created_at DateTime? @db.Timestamptz(6)
updated_at DateTime? @db.Timestamptz(6)
factor_id String? @db.Uuid
aal aal_level?
not_after DateTime? @db.Timestamptz(6)
refreshed_at DateTime? @db.Timestamp(6)
user_agent String?
ip String? @db.Inet
tag String?
oauth_client_id String? @db.Uuid
mfa_amr_claims mfa_amr_claims[]
refresh_tokens refresh_tokens[]
oauth_clients oauth_clients? @relation(fields: [oauth_client_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
users auth_users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
id String @id @db.Uuid
user_id String @db.Uuid
created_at DateTime? @db.Timestamptz(6)
updated_at DateTime? @db.Timestamptz(6)
factor_id String? @db.Uuid
aal aal_level?
not_after DateTime? @db.Timestamptz(6)
refreshed_at DateTime? @db.Timestamp(6)
user_agent String?
ip String? @db.Inet
tag String?
oauth_client_id String? @db.Uuid
refresh_token_hmac_key String?
refresh_token_counter BigInt?
scopes String?
mfa_amr_claims mfa_amr_claims[]
refresh_tokens refresh_tokens[]
oauth_clients oauth_clients? @relation(fields: [oauth_client_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
users auth_users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction)

@@index([not_after(sort: Desc)])
@@index([oauth_client_id])
Expand Down Expand Up @@ -397,23 +403,23 @@ model auth_users {
}

model Comment {
id String @id @default(uuid())
userId String @db.Uuid
postId String?
content String
createdAt DateTime @default(now())
parentId String?
parent_comment Comment? @relation("CommentToComment", fields: [parentId], references: [id], onDelete: SetNull)
child_comment Comment[] @relation("CommentToComment")
Post Post? @relation(fields: [postId], references: [id])
UserProfile UserProfile @relation(fields: [userId], references: [userId])
CommentLike CommentLike[]
id String @id
userId String @db.Uuid
postId String?
content String
createdAt DateTime @default(now())
parentId String?
Comment Comment? @relation("CommentToComment", fields: [parentId], references: [id])
other_Comment Comment[] @relation("CommentToComment")
Post Post? @relation(fields: [postId], references: [id])
UserProfile UserProfile @relation(fields: [userId], references: [userId])
CommentLike CommentLike[]

@@schema("public")
}

model CommentLike {
id String @id @default(uuid())
id String @id
commentId String
userId String @db.Uuid
createdAt DateTime @default(now())
Expand All @@ -424,34 +430,30 @@ model CommentLike {
@@schema("public")
}


// Post model supports both SHORT and LONG posts about movies
// SHORT posts: <=280 chars, no stars
// LONG posts: >280 chars, optional stars (reviews)
model Post {
id String @id @default(uuid())
userId String @db.Uuid
movieId String // Required - all posts must reference a movie
content String
type PostType // SHORT or LONG
stars Int? // Optional star rating (0-10), only for LONG posts
spoiler Boolean @default(false) // Spoiler flag
tags String[] @default([]) // Movie tags from preset list
createdAt DateTime @default(now())
imageUrls String[] @default([])
repostedPostId String? // For reposts/shares - references original post
Comment Comment[]
UserProfile UserProfile @relation(fields: [userId], references: [userId])
PostReaction PostReaction[] // Track individual reactions
OriginalPost Post? @relation("PostReposts", fields: [repostedPostId], references: [id], onDelete: SetNull)
Reposts Post[] @relation("PostReposts")
movie movie @relation(fields: [movieId], references: [movieId])
id String @id
userId String @db.Uuid
movieId String
content String
type PostType
stars Int?
spoiler Boolean @default(false)
tags String[] @default([])
createdAt DateTime @default(now())
imageUrls String[] @default([])
repostedPostId String?
Comment Comment[]
movie movie @relation(fields: [movieId], references: [movieId])
Post Post? @relation("PostToPost", fields: [repostedPostId], references: [id])
other_Post Post[] @relation("PostToPost")
UserProfile UserProfile @relation(fields: [userId], references: [userId])
PostReaction PostReaction[]

@@schema("public")
}

model PostReaction {
id String @id @default(uuid())
id String @id
postId String
userId String @db.Uuid
reactionType ReactionType
Expand All @@ -463,19 +465,15 @@ model PostReaction {
@@schema("public")
}

// DEPRECATED: Use Post model instead for all movie content
// This model is kept for backward compatibility only
// All relations removed - this is a standalone legacy model
// DO NOT USE THIS MODEL
model Rating {
id String @id @default(uuid())
userId String @db.Uuid
movieId String
stars Int
comment String?
tags String[] @default([])
date DateTime
votes Int @default(0)
id String @id
userId String @db.Uuid
movieId String
stars Int
comment String?
tags String[] @default([])
date DateTime
votes Int @default(0)

@@schema("public")
}
Expand All @@ -500,12 +498,18 @@ model UserProfile {
profilePicture String?
country String?
city String?
displayName String?
favoriteGenres String[] @default([])
favoriteMovies String[] @default([])
privateAccount Boolean @default(false)
spoiler Boolean @default(false)
bio String?
moviesToWatch String[] @default([])
moviesCompleted String[] @default([])
eventsSaved String[] @default([])
eventsAttended String[] @default([])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
updatedAt DateTime
Comment Comment[]
CommentLike CommentLike[]
Post Post[]
Expand All @@ -528,8 +532,22 @@ model bootcamp {
@@schema("public")
}

model event_rsvp {
id String @id @db.Uuid
eventId String @db.Uuid
userId String @db.Uuid
status String
createdAt DateTime @default(now())
updatedAt DateTime
local_event local_event @relation(fields: [eventId], references: [id], onDelete: Cascade)
UserProfile UserProfile @relation(fields: [userId], references: [userId], onDelete: Cascade)

@@unique([eventId, userId])
@@schema("public")
}

model local_event {
id String @id(map: "local_events_pkey") @default(uuid()) @db.Uuid
id String @id(map: "local_events_pkey") @db.Uuid
title String
time DateTime? @default(dbgenerated("(now() AT TIME ZONE 'utc'::text)")) @db.Timestamptz(6)
description String
Expand All @@ -545,22 +563,8 @@ model local_event {
@@schema("public")
}

model event_rsvp {
id String @id @default(uuid()) @db.Uuid
eventId String @db.Uuid
userId String @db.Uuid
status String // 'yes', 'maybe', 'no'
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
local_event local_event @relation(fields: [eventId], references: [id], onDelete: Cascade)
UserProfile UserProfile @relation(fields: [userId], references: [userId], onDelete: Cascade)

@@unique([eventId, userId])
@@schema("public")
}

model movie {
movieId String @id
movieId String @id
localRating String?
imdbRating BigInt?
languages Json?
Expand All @@ -570,7 +574,7 @@ model movie {
imageUrl String?
releaseYear Int?
director String?
Post Post[] // All movie posts (SHORT and LONG)
Post Post[]

@@schema("public")
}
Expand Down Expand Up @@ -662,10 +666,10 @@ enum PostType {
}

enum ReactionType {
SPICY // 🌶️ Drama-filled, bold, or full of tension
STAR_STUDDED // ✨ Packed with A-listers
THOUGHT_PROVOKING // 🧠 Thought-provoking/mind blowing
BLOCKBUSTER // 🧨 Mega-hit with hype, memes, and madness
SPICY
STAR_STUDDED
THOUGHT_PROVOKING
BLOCKBUSTER

@@schema("public")
}
Loading