// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

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

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

model VendorPrice {
  id            String   @id @default(uuid())
  timestamp     DateTime @default(now()) @db.Timestamptz(3)
  vendor        String   // 'eldorado' or 'playerauctions'
  sellerName    String?  @map("seller_name")
  usdPrice      Decimal  @map("usd_price") @db.Decimal(12, 2)
  auecAmount    BigInt   @map("auec_amount")
  usdPerMillion Decimal  @map("usd_per_million") @db.Decimal(13, 9)
  deliveryTime  String?  @map("delivery_time")
  url           String

  @@index([timestamp])
  @@index([vendor])
  @@index([sellerName])
  @@index([usdPerMillion])
  @@map("raw_vendor_prices")
}

model PriceIndex {
  id          String   @id @default(uuid())
  timestamp   DateTime @default(now()) @db.Timestamptz(3)
  lowestPrice Decimal  @map("lowest_price") @db.Decimal(13, 9)
  vendor      String
  sellerName  String?  @map("seller_name")

  @@index([timestamp])
  @@map("price_index")
}

model ScrapeLog {
  id        String   @id @default(uuid())
  timestamp DateTime @default(now()) @db.Timestamptz(3)
  status    String   // 'success' or 'failure'
  message   String?
  runtimeMs Int?     @map("runtime_ms")

  @@index([timestamp])
  @@map("scrape_log")
}
