Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

2.9 KB
Raw Blame
model Subscription {
  id                 String               @id
  priceId            String               @map("price_id")
  quantity           Int                  @default(1)
  subscriptionItemId String               @map("subscription_item_id")
  amount             Int
  discountPercentOff Float?               @map("discount_percent_off")
  discountAmountOff  Int?                 @map("discount_amount_off")
  status             SubscriptionStatus
  active             Boolean
  currency           String
  interval           SubscriptionInterval
  createdAt          DateTime             @default(now()) @map("created_at")
  periodStart        DateTime             @map("period_start")
  periodEnd          DateTime             @map("period_end")
  cancelAtPeriodEnd  Boolean              @default(false) @map("cancel_at_period_end")
  userId             String               @map("user_id")
  spaceId            String               @map("space_id")

  user  User  @relation("UserToSubscription", fields: [userId], references: [id], onDelete: Cascade)
  space Space @relation("SpaceToSubscription", fields: [spaceId], references: [id], onDelete: Cascade)

  @@index([userId])
  @@index([spaceId])
  @@map("subscriptions")
}

enum SubscriptionStatus {
  incomplete
  incomplete_expired
  active
  paused
  trialing
  past_due
  canceled
  unpaid

  @@map("subscription_status")
}

enum SubscriptionInterval {
  month
  year

  @@map("subscription_interval")
}

model PaymentMethod {
  id        String   @id
  userId    String   @map("user_id")
  type      String
  data      Json
  createdAt DateTime @default(now()) @map("created_at")
  updatedAt DateTime @updatedAt @map("updated_at")

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@map("payment_methods")
}

enum NonprofitApplicationStatus {
  approved
  rejected
  // The verifier could not reach a verdict (model error, unreadable upload).
  failed

  @@map("nonprofit_application_status")
}

model NonprofitApplication {
  id               String                     @id @default(uuid())
  spaceId          String                     @map("space_id")
  userId           String                     @map("user_id")
  organizationName String                     @map("organization_name")
  website          String
  emailDomain      String                     @map("email_domain")
  status           NonprofitApplicationStatus
  // Verifier's explanation; shown to the applicant on rejection.
  reason           String?
  // Model that produced the verdict, kept for auditing the automated review.
  model            String?
  createdAt        DateTime                   @default(now()) @map("created_at")

  space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade)
  user  User  @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@index([spaceId, createdAt])
  @@map("nonprofit_applications")
}