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

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

model User {
  id        Int      @id @default(autoincrement())
  username  String   @unique
  password  String
  role      String   @default("admin")
  fullName  String?
  photo     String?
  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @updatedAt @map("updated_at")

  @@map("users")
}

model Article {
  id        Int      @id @default(autoincrement())
  title     String
  slug      String   @unique
  content   String
  excerpt   String?
  category  String
  author    String?
  image     String?
  status    String   @default("draft")
  tags      String?
  metaTitle String?  @map("meta_title")
  metaDesc  String?  @map("meta_desc")
  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @updatedAt @map("updated_at")

  @@map("articles")
}

model Promo {
  id          Int      @id @default(autoincrement())
  title       String
  slug        String   @unique
  description String?
  image       String?
  normalPrice String?
  promoPrice  String?
  discount    String?
  periodStart DateTime? @map("period_start")
  periodEnd   DateTime? @map("period_end")
  category    String   @default("general")
  featured    Boolean  @default(false)
  isActive    Boolean  @default(true)
  createdAt   DateTime @default(now()) @map("created_at")
  updatedAt   DateTime @updatedAt @map("updated_at")

  @@map("promos")
}

model Location {
  id          Int      @id @default(autoincrement())
  name        String
  address     String
  city        String
  phone       String?
  whatsapp    String?
  latitude    Float?
  longitude   Float?
  type        String   @default("Skin Clinic")
  createdAt   DateTime @default(now()) @map("created_at")
  updatedAt   DateTime @updatedAt @map("updated_at")

  @@map("locations")
}

model Testimonial {
  id        Int      @id @default(autoincrement())
  name      String
  slug      String   @unique
  text      String
  rating    Int      @default(5)
  photo     String?
  position  String?
  isActive  Boolean  @default(true)
  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @updatedAt @map("updated_at")

  @@map("testimonials")
}

model Treatment {
  id          Int      @id @default(autoincrement())
  name        String
  slug        String   @unique
  category    String
  description String
  benefits    String?
  isActive    Boolean  @default(true)
  createdAt   DateTime @default(now()) @map("created_at")
  updatedAt   DateTime @updatedAt @map("updated_at")

  @@map("treatments")
}

model TreatmentCategory {
  id          Int      @id @default(autoincrement())
  name        String
  slug        String   @unique
  description String?
  createdAt   DateTime @default(now()) @map("created_at")
  updatedAt   DateTime @updatedAt @map("updated_at")

  @@map("treatment_categories")
}

model PromoCategory {
  id        Int      @id @default(autoincrement())
  name      String
  slug      String   @unique
  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @updatedAt @map("updated_at")

  @@map("promo_categories")
}

model Booking {
  id        Int      @id @default(autoincrement())
  name      String
  phone     String
  email     String?
  branch    String
  category  String
  treatment String
  date      String
  time      String
  notes     String?
  status    String   @default("pending")
  createdAt DateTime @default(now()) @map("created_at")

  @@map("bookings")
}

model Banner {
  id         Int      @id @default(autoincrement())
  title      String
  subtitle   String?
  image      String?
  link       String?
  buttonText String?
  sortOrder  Int      @default(1)
  isActive   Boolean  @default(true)
  createdAt  DateTime @default(now()) @map("created_at")
  updatedAt  DateTime @updatedAt @map("updated_at")

  @@map("banners")
}

model Doctor {
  id          Int      @id @default(autoincrement())
  name        String
  slug        String   @unique
  title       String?  // Sp.KK, Sp.DV, etc
  specialty   String?  // Dermatologi, Venereologi, dll
  bio         String?  @db.Text
  photo       String?
  education   String?  @db.Text
  experience  String?  // "15+ tahun pengalaman"
  services    String?  // JSON array of treatment slugs
  isActive    Boolean  @default(true)
  sortOrder   Int      @default(0)
  createdAt   DateTime @default(now()) @map("created_at")
  updatedAt   DateTime @updatedAt @map("updated_at")

  @@map("doctors")
}

model ArticleCategory {
  id        Int      @id @default(autoincrement())
  name      String
  slug      String   @unique
  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @updatedAt @map("updated_at")

  @@map("article_categories")
}
