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

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

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

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

enum FundSlug {
  monero
  firo
  privacyguides
  general
}

model Donation {
  id        String   @id @default(cuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  userId                String?
  btcPayInvoiceId       String?
  stripePaymentIntentId String? // For donations and non-recurring memberships
  stripeInvoiceId       String?   @unique // For recurring memberships
  stripeSubscriptionId  String? // For recurring memberships
  projectSlug           String
  projectName           String
  fundSlug              FundSlug
  cryptoCode            String?
  grossCryptoAmount     Float?
  netCryptoAmount       Float?
  grossFiatAmount       Float
  netFiatAmount         Float
  pointsAdded           Int       @default(0)
  membershipExpiresAt   DateTime?

  @@index([btcPayInvoiceId])
  @@index([stripePaymentIntentId])
  @@index([stripeSubscriptionId])
  @@index([userId])
}

model ProjectAddresses {
  id        String   @id @default(cuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  projectSlug     String
  fundSlug        FundSlug
  btcPayInvoiceId String
  bitcoinAddress  String
  moneroAddress   String

  @@unique([projectSlug, fundSlug])
}
