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

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

model User {
  id       Int     @id @default(autoincrement())
  username String  @unique
  password String
  role     String? @default("admin")

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

model Doctor {
  id            Int     @id @default(autoincrement())
  doctorId      String  @unique
  name          String
  designation   String?
  workingStatus String?
  qualification String?

  departments  DoctorDepartment[]
  appointments Appointment[]

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

model Department {
  id           Int    @id @default(autoincrement())
  departmentId String @unique
  name         String

  para1      String?
  para2      String?
  para3      String?
  facilities String?
  services   String?

  doctors      DoctorDepartment[]
  appointments Appointment[]

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

model DoctorDepartment {
  id Int @id @default(autoincrement())

  doctorId     Int
  departmentId Int

  doctor     Doctor     @relation(fields: [doctorId], references: [id])
  department Department @relation(fields: [departmentId], references: [id])

  timing DoctorTiming?

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

  @@unique([doctorId, departmentId])
}

model DoctorTiming {
  id Int @id @default(autoincrement())

  doctorDepartmentId Int              @unique
  doctorDepartment   DoctorDepartment @relation(fields: [doctorDepartmentId], references: [id])

  monday     String?
  tuesday    String?
  wednesday  String?
  thursday   String?
  friday     String?
  saturday   String?
  sunday     String?
  additional String?

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

model Blog {
  id       Int     @id @default(autoincrement())
  title    String
  writer   String?
  image    String?
  content  Json
  isActive Boolean @default(true)

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

model Career {
  id             Int     @id @default(autoincrement())
  post           String
  designation    String?
  qualification  String?
  experienceNeed String?
  email          String?
  number         String?
  status         String  @default("new")

  candidates Candidate[]

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

model Candidate {
  id          Int    @id @default(autoincrement())
  fullName    String
  mobile      String
  email       String
  subject     String
  coverLetter String
  careerId    Int

  career Career @relation(fields: [careerId], references: [id])

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

model Appointment {
  id Int @id @default(autoincrement())

  name         String
  mobileNumber String
  email        String?
  message      String?
  date         DateTime

  doctorId     String
  departmentId String

  doctor     Doctor     @relation(fields: [doctorId], references: [doctorId])
  department Department @relation(fields: [departmentId], references: [departmentId])

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

model Inquiry {
  id        Int      @id @default(autoincrement())

  fullName  String
  number    String
  emailId   String?
  subject   String?
  message   String?

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

model AcademicsResearch {
  id         Int      @id @default(autoincrement())

  fullName   String
  number     String
  emailId    String?
  subject    String?
  courseName String?
  message    String?

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


model EmailConfig {
  id        Int    @id @default(autoincrement())
  name      String 
  email     String
  type      String 
  isActive  Boolean @default(true)

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

model NewsMedia {
  id         Int      @id @default(autoincrement())

  headline   String
  content    String?
  firstPara  String?
  secondPara String?
  author     String?
  date       DateTime?

  isActive   Boolean  @default(true)

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