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

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

model Admin {
  id            String    @id @default(cuid()) @db.VarChar(255)
  name          String    @db.VarChar(40)
  email         String    @db.VarChar(255)
  social_id     String    @db.VarChar(40)
  login_type    String    @db.VarChar(10)
  picture       String    @db.VarChar(255)
  accesstoken   String    @db.VarChar(255)
  updated_at    DateTime  @default(now())
  created_at    DateTime  @default(now())

  @@map("admin")
}

model Program {
  id            String    @id @default(cuid()) @db.VarChar(255)
  course        String    @db.VarChar(40)
  subject       String    @db.VarChar(255)
  content       String    @db.VarChar(512)
  tag           Json
  status        String    @db.VarChar(10)
  publish_at    DateTime  @db.Date
  updated_at    DateTime  @default(now())
  created_at    DateTime  @default(now())
  quizzes       Quiz[]

  @@map("program")

  @@index([course])
  @@index([tag])
  @@index([status])
  @@index([updated_at])
  @@index([created_at])
}

model Quiz {
  id            String    @id @default(cuid())
  program_id    String    @db.VarChar(255)
  sequence      Int
  quiz_type     String    @db.VarChar(10)
  question      String    @db.VarChar(512)
  choice        Json
  answer        Json
  comment       String    @db.VarChar(512)
  hint          String    @db.VarChar(512)
  updated_at    DateTime  @default(now())
  created_at    DateTime  @default(now())
  program       Program?  @relation(fields: [program_id], references: [id])

  @@map("quiz")

  @@index([program_id])
  @@index([sequence])
  @@index([quiz_type])
  @@index([updated_at])
  @@index([created_at])
}