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

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

model Product {
  id        String   @id @default(cuid())
  slug      String   @unique
  sortOrder Int      @default(0)

  // Card data (data-* attributes)
  index     String // e.g. "PROJET_001"
  name      String // e.g. "Solar_Altar"
  type      String // e.g. "LAMPE DE TABLE"
  materials String
  year      String
  status    String // e.g. "PROTOTYPE [80%]"
  description String
  specs     String
  notes     String
  imagePath String
  imageAlt  String @default("")

  // SEO
  seoTitle       String
  seoDescription String
  ogImage        String

  // Commerce
  productDisplayName String
  price              Int?    // cents, null = not for sale
  currency           String  @default("EUR")
  availability       String  @default("https://schema.org/PreOrder")
  stripePriceId      String? // Stripe price_id
  stripeKey          String? // compat frontend e.g. "lumiere_orbitale"
  isPublished        Boolean @default(true)

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  orders Order[]
}

model Order {
  id                  String   @id @default(cuid())
  stripeSessionId     String   @unique
  stripePaymentIntent String?
  status              String   @default("pending")
  amount              Int
  currency            String   @default("EUR")
  customerEmail       String?
  receiptUrl          String?

  productId   String?
  product     Product? @relation(fields: [productId], references: [id])
  productSlug String?

  metadata Json?

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

model AdminUser {
  id           String   @id @default(cuid())
  email        String   @unique
  passwordHash String
  createdAt    DateTime @default(now())
}
