// 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("DATABASE_URL") } model Account { id String @id @default(cuid()) userId String @unique type String provider String providerAccountId String refresh_token String? @db.Text access_token String? @db.Text expires_at Int? token_type String? scope String? id_token String? @db.Text session_state String? createdAt DateTime @default(now()) @map(name: "created_at") updatedAt DateTime @default(now()) @map(name: "updated_at") refresh_token_expires_in Int? user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([provider, providerAccountId]) @@map(name: "accounts") } model Session { id String @id @default(cuid()) sessionToken String @unique userId String @unique expires DateTime user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@map(name: "sessions") } model User { id String @id @default(cuid()) name String? username String? @unique @map("usernames") email String? @unique emailVerified DateTime? password String? image String? createdAt DateTime @default(now()) @map(name: "created_at") updatedAt DateTime @default(now()) @map(name: "updated_at") accounts Account[] sessions Session[] Post Post[] Comment Comment[] Like Like[] followers Follows[] @relation("follower") following Follows[] @relation("following") @@map(name: "users") } model VerificationToken { identifier String token String @unique expires DateTime @@unique([identifier, token]) @@map(name: "verification_tokens") } model Follows { follower User @relation("following", fields: [followerId], references: [id]) followerId String following User @relation("follower", fields: [followingId], references: [id]) followingId String createdAt DateTime @default(now()) @@id([followerId, followingId]) @@map(name: "follows") } model Post { id String @id @default(cuid()) createdAt DateTime @default(now()) @map(name: "created_at") updatedAt DateTime @default(now()) @map(name: "updated_at") userId String content String likeCount Int? @default(0) published Boolean @default(false) user User @relation(fields: [userId], references: [id], onDelete: Cascade) Comment Comment[] Like Like[] @@map(name: "posts") } model Like { id String @id @default(cuid()) postId String commentId String? userId String post Post @relation(fields: [postId], references: [id], onDelete: Cascade) comment Comment? @relation(fields: [commentId], references: [id], onDelete: Cascade) user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@map(name: "likes") } model Comment { id String @id @default(cuid()) createdAt DateTime @default(now()) @map(name: "created_at") updatedAt DateTime @default(now()) @map(name: "updated_at") message String likeCount Int? @default(0) postId String userId String post Post @relation(fields: [postId], references: [id], onDelete: Cascade) user User @relation(fields: [userId], references: [id], onDelete: Cascade) Like Like[] @@map(name: "comments") }