// 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("POSTGRES_URL_NON_POOLING") // used for migrations } model User { id String @id @default(uuid()) 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) isAccountVerified Boolean @default(false) dateOfBirth DateTime beerPosts BeerPost[] beerTypes BeerType[] breweryPosts BreweryPost[] beerComments BeerComment[] breweryComments BreweryComment[] BeerPostLikes BeerPostLike[] BeerImage BeerImage[] BreweryImage BreweryImage[] BreweryPostLike BreweryPostLike[] Location Location[] } model BeerPost { id String @id @default(uuid()) 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 type BeerType @relation(fields: [typeId], references: [id], onDelete: Cascade) typeId 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(uuid()) 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(uuid()) 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(uuid()) 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 BeerType { id String @id @default(uuid()) name 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 beerPosts BeerPost[] } model Location { id String @id @default(uuid()) city String stateOrProvince String? country String? coordinates Float[] address String postedBy User @relation(fields: [postedById], references: [id], onDelete: Cascade) postedById String BreweryPost BreweryPost? } model BreweryPost { id String @id @default(uuid()) name String location Location @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(uuid()) 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(uuid()) 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(uuid()) 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 }