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

datasource db {
  provider     = "mysql"
  url          = env("PRISMA_URL")
  relationMode = "prisma"
}

model Maintenance {
  id        Int      @id @default(autoincrement())
  reason    String   @default("")
  beginAt   DateTime @default(now())
  endAt     DateTime @default(now())
  createdAt DateTime @default(now())
  enabled   Boolean  @default(true)
}

model Announcement {
  id        Int      @id @default(autoincrement())
  createdAt DateTime @default(now())
  content   String   @default("")
}

enum CategoryType {
  TALENT
  BOOKMARK
}

model Category {
  id        Int                     @id @default(autoincrement())
  createdAt DateTime                @default(now())
  slug      String                  @default("")
  name      String                  @default("")
  type      CategoryType            @default(TALENT)
  talents   CategoriesOnTalents[]
  bookmarks CategoriesOnBookmarks[]
}

model Talent {
  id         Int                   @id @default(autoincrement())
  createdAt  DateTime              @default(now())
  logo       String                @default("")
  name       String                @unique @default("")
  website    String                @default("")
  work       String                @default("")
  favorite   Boolean               @default(false)
  categories CategoriesOnTalents[]
}

model Bookmark {
  id         Int                     @id @default(autoincrement())
  createdAt  DateTime                @default(now())
  name       String                  @unique @default("")
  website    String                  @default("")
  favorite   Boolean                 @default(false)
  categories CategoriesOnBookmarks[]
}

model CategoriesOnTalents {
  talentId   Int
  categoryId Int
  category   Category @relation(fields: [categoryId], references: [id])
  talent     Talent   @relation(fields: [talentId], references: [id])

  @@id([talentId, categoryId])
  @@index([talentId])
  @@index([categoryId])
}

model CategoriesOnBookmarks {
  bookmarkId Int
  categoryId Int
  category   Category @relation(fields: [categoryId], references: [id])
  bookmark   Bookmark @relation(fields: [bookmarkId], references: [id])

  @@id([bookmarkId, categoryId])
  @@index([bookmarkId])
  @@index([categoryId])
}

model Post {
  id        Int      @id @default(autoincrement())
  slug      String   @unique @default("")
  createdAt DateTime @default(now())
  views     Int      @default(0)
  likes     Int      @default(0)
}

model Suggestion {
  id        Int      @id @default(autoincrement())
  email     String   @unique @default("")
  content   String   @default("")
  added     Boolean  @default(false)
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model Form {
  id        Int      @id @default(autoincrement())
  name      String   @default("")
  email     String   @default("")
  content   String   @default("")
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model GuestbookMessage {
  id        Int      @id @default(autoincrement())
  message   String   @default("")
  email     String   @unique @default("")
  image     String   @default("")
  username  String   @default("")
  updatedAt DateTime @updatedAt
  createdAt DateTime @default(now())
}
