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

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

model Article {
  id                  Int                 @id @default(autoincrement())
  name                String              @unique
  title               String              @unique
  introduction        String              @default("")
  imageId             Int?
  image               Image?              @relation(fields: [imageId], references: [id])
  markdown            String
  contentTableEntries ContentTableEntry[]
  categoryId          Int
  category            Category            @relation(fields: [categoryId], references: [id])
  dateCreated         DateTime            @default(now())
  dateUpdated         DateTime            @default(now())
}

model ContentTableEntry {
  id          Int      @id @default(autoincrement())
  title       String
  anchor      String
  orderIndex  Int
  articleId   Int
  article     Article  @relation(fields: [articleId], references: [id])
  dateCreated DateTime @default(now())
  dateUpdated DateTime @default(now())
}

model Category {
  id          Int       @id @default(autoincrement())
  name        String    @unique
  title       String    @unique
  color       String    @unique
  svgId       Int
  svg         Svg       @relation(fields: [svgId], references: [id])
  Article     Article[]
  dateCreated DateTime  @default(now())
  dateUpdated DateTime  @default(now())
}

model Image {
  id          Int       @id @default(autoincrement())
  name        String    @unique
  alt         String    @default("")
  url         String    @default("")
  dateCreated DateTime  @default(now())
  Article     Article[]
}

model Svg {
  id       Int        @id @default(autoincrement())
  name     String     @unique
  path     String     @default("")
  viewbox  String     @default("0 0 512 512")
  Category Category[]
}
