generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
}

model User {
  id        String   @id @default(cuid())
  email     String   @unique
  name      String
  password  String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model Session {
  id         String     @id @default(cuid())
  visitorId  String
  startedAt  DateTime   @default(now())
  lastSeenAt DateTime   @updatedAt
  pageViews  PageView[]
}

model PageView {
  id        String   @id @default(cuid())
  sessionId String
  path      String
  createdAt DateTime @default(now())

  session Session @relation(fields: [sessionId], references: [id])
}

model Project {
  id          String   @id @default(cuid())
  title       String
  description String
  imageUrl    String?
  liveUrl     String?
  githubUrl   String?
  techStack   String[] // Array of tech names
  featured    Boolean  @default(false)
  order       Int      @default(0)
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
}

model Experience {
  id          String    @id @default(cuid())
  company     String
  role        String
  startDate   DateTime
  endDate     DateTime?
  current     Boolean   @default(false)
  description String
  highlights  String[]
  techStack   String[]
  order       Int       @default(0)
  createdAt   DateTime  @default(now())
  updatedAt   DateTime  @updatedAt
}

model ContactMessage {
  id        String   @id @default(cuid())
  name      String
  email     String
  subject   String
  message   String
  read      Boolean  @default(false)
  createdAt DateTime @default(now())
}

enum BlogStatus {
  DRAFT
  SCHEDULED
  PUBLISHED
}

model Blog {
  id      String  @id @default(cuid())
  title   String
  slug    String  @unique
  content String
  excerpt String?

  status      BlogStatus @default(DRAFT)
  scheduledAt DateTime?
  publishedAt DateTime?

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  tags Tag[]

  @@index([status])
  @@index([scheduledAt])
}

model Tag {
  id        String   @id @default(cuid())
  name      String   @unique
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  blogs Blog[]
}
