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

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

enum Role {
  ADMIN
  USER
}

model User {
  id            String    @id @default(cuid())
  name          String?
  email         String    @unique
  emailVerified DateTime?
  image         String?
  password      String?
  role          Role      @default(USER)
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt
  deletedAt     DateTime?
  accounts      Account[]
  sessions      Session[]
}

model Account {
  id                String  @id @default(cuid())
  userId            String
  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?
  user              User    @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

model Session {
  id           String   @id @default(cuid())
  sessionToken String   @unique
  userId       String
  expires      DateTime
  user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model VerificationToken {
  identifier String
  token      String   @unique
  expires    DateTime

  @@unique([identifier, token])
}

// Daire tipleri
model Unit {
  id          String    @id @default(cuid())
  slug        String    @unique
  typeTr      String    // "2+1 Tip A"
  typeEn      String    // "2+1 Type A"
  size        Float     // m²
  rooms       Int       // oda sayısı
  bathrooms   Int       @default(1)
  floor       String?   // "1-3. Kat"
  descTr      String?   @db.Text
  descEn      String?   @db.Text
  imageUrl    String?
  planUrl     String?   // kat planı görseli
  featured    Boolean   @default(false)
  available   Boolean   @default(true)
  order       Int       @default(0)
  createdAt   DateTime  @default(now())
  updatedAt   DateTime  @updatedAt
  deletedAt   DateTime?
}

// Galeri
model Gallery {
  id        String    @id @default(cuid())
  titleTr   String
  titleEn   String
  imageUrl  String
  category  String    @default("general") // "exterior" | "interior" | "amenities" | "location"
  order     Int       @default(0)
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
  deletedAt DateTime?
}

// İletişim mesajları
model ContactMessage {
  id        String    @id @default(cuid())
  fullName  String
  email     String
  phone     String?
  message   String    @db.Text
  read      Boolean   @default(false)
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
  deletedAt DateTime?
}
