Skip to content

Open source CapCut alternative.

TypeScript
1.6 KB
Raw Blame
// Donkey Pro: the Mac app subscription. While active it includes a monthly
// inference allowance equal to the plan price, granted into the user's credit
// balance as an expiring grant (source "pro_subscription") so it is drawn down
// before never-expiring purchased credits and does not roll over.
// monthlyAllowanceMicros mirrors the included amount (the price), for display.
model ProSubscription {
  id                     String    @id @default(cuid())
  userId                 String    @unique
  user                   User      @relation(fields: [userId], references: [id], onDelete: Cascade)
  stripeCustomerId       String?
  stripeSubscriptionId   String?   @unique
  status                 String    @default("incomplete")
  planKey                String    @default("pro")
  monthlyAllowanceMicros BigInt    @default(0)
  currentPeriodStart     DateTime?
  currentPeriodEnd       DateTime?
  cancelAtPeriodEnd      Boolean   @default(false)
  // Stripe's cancel_at: when a scheduled cancel ends the subscription. Null
  // while nothing is scheduled.
  cancelAt               DateTime?
  // Stripe's ended_at: when the subscription ended. Null while it runs.
  endedAt                DateTime?
  createdAt              DateTime  @default(now())
  updatedAt              DateTime  @updatedAt

  @@map("pro_subscription")
}

// When an account first saw the intro offer. Its window runs once, from here;
// a row exists only for an account a surface has shown the offer to.
model IntroOfferView {
  userId String   @id
  user   User     @relation(fields: [userId], references: [id], onDelete: Cascade)
  seenAt DateTime @default(now())

  @@map("intro_offer_view")
}