generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["postgresqlExtensions"]
}

datasource db {
  provider  = "postgresql"
  url       = env("POSTGRES_PRISMA_URL")
  directUrl = env("POSTGRES_URL_NON_POOLING")
}

model Maintenance {
  id        Int      @id @default(autoincrement())
  reason    String
  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
}

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

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

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 BookMark {
  id                    Int                     @id @default(autoincrement())
  createdAd             DateTime                @default(now())
  name                  String
  description           String
  link                  String
  CategoriesOnBookMarks CategoriesOnBookMarks[]
}

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

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

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

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

enum CategoryType {
  TALENT
  BOOKMARK
}
