// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("POSTGRES_PRISMA_URL") // uses connection pooling directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection shadowDatabaseUrl = env("SHADOW_DATABASE_URL") } enum Role { USER ADMIN } model User { id String @id @default(cuid()) username String @unique firstName String lastName String hash String email String @unique createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) accountIsVerified Boolean @default(false) dateOfBirth DateTime role Role @default(USER) bio String? beerPosts BeerPost[] beerStyles BeerStyle[] breweryPosts BreweryPost[] beerComments BeerComment[] breweryComments BreweryComment[] beerPostLikes BeerPostLike[] beerImages BeerImage[] breweryImages BreweryImage[] breweryPostLikes BreweryPostLike[] locations BreweryLocation[] glasswares Glassware[] beerStyleLikes BeerStyleLike[] beerStyleComments BeerStyleComment[] userAvatar UserAvatar? followedBy UserFollow[] @relation("following") following UserFollow[] @relation("follower") } model UserFollow { follower User @relation("follower", fields: [followerId], references: [id]) followerId String following User @relation("following", fields: [followingId], references: [id]) followingId String followedAt DateTime @default(now()) @db.Timestamptz(3) @@id([followerId, followingId]) } model UserAvatar { id String @id @default(cuid()) path String alt String caption String user User @relation(fields: [userId], references: [id], onDelete: Cascade) userId String @unique createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) } model BeerPost { id String @id @default(cuid()) name String ibu Float abv Float description String postedBy User @relation(fields: [postedById], references: [id], onDelete: Cascade) postedById String brewery BreweryPost @relation(fields: [breweryId], references: [id], onDelete: Cascade) breweryId String style BeerStyle @relation(fields: [styleId], references: [id], onDelete: Cascade) styleId String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) beerComments BeerComment[] beerImages BeerImage[] beerPostLikes BeerPostLike[] } model BeerPostLike { id String @id @default(cuid()) beerPost BeerPost @relation(fields: [beerPostId], references: [id], onDelete: Cascade) beerPostId String likedBy User @relation(fields: [likedById], references: [id], onDelete: Cascade) likedById String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) } model BreweryPostLike { id String @id @default(cuid()) breweryPost BreweryPost @relation(fields: [breweryPostId], references: [id], onDelete: Cascade) breweryPostId String likedBy User @relation(fields: [likedById], references: [id], onDelete: Cascade) likedById String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) } model BeerComment { id String @id @default(cuid()) rating Int beerPost BeerPost @relation(fields: [beerPostId], references: [id], onDelete: Cascade) beerPostId String postedBy User @relation(fields: [postedById], references: [id], onDelete: Cascade) postedById String content String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) } model BeerStyle { id String @id @default(cuid()) name String description String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) postedBy User @relation(fields: [postedById], references: [id], onDelete: Cascade) glassware Glassware @relation(fields: [glasswareId], references: [id], onDelete: Cascade) glasswareId String postedById String abvRange Float[] ibuRange Float[] beerPosts BeerPost[] beerStyleLike BeerStyleLike[] beerStyleComment BeerStyleComment[] } model BeerStyleLike { id String @id @default(cuid()) beerStyle BeerStyle @relation(fields: [beerStyleId], references: [id], onDelete: Cascade) beerStyleId String likedBy User @relation(fields: [likedById], references: [id], onDelete: Cascade) likedById String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) } model BeerStyleComment { id String @id @default(cuid()) rating Int beerStyle BeerStyle @relation(fields: [beerStyleId], references: [id], onDelete: Cascade) beerStyleId String postedBy User @relation(fields: [postedById], references: [id], onDelete: Cascade) postedById String content String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) } model Glassware { id String @id @default(cuid()) name String description String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) postedBy User @relation(fields: [postedById], references: [id], onDelete: Cascade) postedById String beerStyle BeerStyle[] } model BreweryLocation { id String @id @default(cuid()) city String stateOrProvince String? country String? coordinates Float[] address String postedBy User @relation(fields: [postedById], references: [id], onDelete: Cascade) postedById String breweryPost BreweryPost? createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) } model BreweryPost { id String @id @default(cuid()) name String location BreweryLocation @relation(fields: [locationId], references: [id]) locationId String @unique beers BeerPost[] description String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) postedBy User @relation(fields: [postedById], references: [id], onDelete: Cascade) postedById String breweryComments BreweryComment[] breweryImages BreweryImage[] breweryPostLike BreweryPostLike[] dateEstablished DateTime @default(now()) @db.Timestamptz(3) } model BreweryComment { id String @id @default(cuid()) rating Int breweryPost BreweryPost @relation(fields: [breweryPostId], references: [id], onDelete: Cascade) breweryPostId String postedBy User @relation(fields: [postedById], references: [id], onDelete: Cascade) postedById String content String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) } model BeerImage { id String @id @default(cuid()) beerPost BeerPost @relation(fields: [beerPostId], references: [id], onDelete: Cascade) beerPostId String path String alt String caption String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) postedBy User @relation(fields: [postedById], references: [id], onDelete: Cascade) postedById String } model BreweryImage { id String @id @default(cuid()) breweryPost BreweryPost @relation(fields: [breweryPostId], references: [id], onDelete: Cascade) breweryPostId String path String createdAt DateTime @default(now()) @db.Timestamptz(3) updatedAt DateTime? @updatedAt @db.Timestamptz(3) caption String alt String postedBy User @relation(fields: [postedById], references: [id], onDelete: Cascade) postedById String }