Skip to content

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

4.8 KB
Raw Blame
enum TimeFormat {
  hours12
  hours24

  @@map("time_format")
}

model Account {
  id                String  @id @default(cuid())
  userId            String  @map("user_id")
  provider          String
  providerAccountId String  @map("provider_account_id")
  refresh_token     String? @db.Text
  access_token      String? @db.Text
  expires_at        Int?
  scope             String?
  id_token          String? @db.Text

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

  accessTokenExpiresAt  DateTime? @map("access_token_expires_at")
  refreshTokenExpiresAt DateTime? @map("refresh_token_expires_at")
  password              String?   @map("password")
  createdAt             DateTime  @default(now()) @map("created_at")
  updatedAt             DateTime  @updatedAt @map("updated_at")

  @@unique([provider, providerAccountId])
  @@index([userId])
  @@map("accounts")
}

enum UserRole {
  admin
  user

  @@map("user_role")
}

model User {
  id                String      @id @default(cuid())
  name              String
  email             String      @unique @db.Citext
  emailVerified     Boolean?    @map("email_verified")
  image             String?
  timeZone          String?     @map("time_zone")
  weekStart         Int?        @map("week_start")
  timeFormat        TimeFormat? @map("time_format")
  locale            String?
  createdAt         DateTime    @default(now()) @map("created_at")
  updatedAt         DateTime?   @updatedAt @map("updated_at")
  customerId        String?     @map("customer_id")
  banned            Boolean     @default(false)
  bannedAt          DateTime?   @map("banned_at")
  banReason         String?     @map("ban_reason")
  banExpires        DateTime?   @map("ban_expires")
  role              UserRole    @default(user)
  lastLoginMethod   String?     @map("last_login_method")
  isAnonymous       Boolean     @default(false) @map("anonymous")
  lastSeenAt        DateTime    @default(now()) @map("last_seen_at")
  deletedAt         DateTime?   @map("deleted_at")
  // Self-declared role, optional. Free-form string rather than an enum so
  // the taxonomy can change without a migration; validation lives in
  // features/user/schema.ts.
  jobTitle          String?     @map("job_title")
  // When the user was asked for a review on a third-party site, by the
  // review request email or a one-off campaign. Asked once per user, so a set
  // value means never ask again.
  reviewRequestedAt DateTime?   @map("review_requested_at")

  comments                Comment[]
  polls                   Poll[]
  notificationPreferences UserNotificationPreferences?
  queuedEmails            QueuedEmail[]
  accounts                Account[]
  participants            Participant[]
  paymentMethods          PaymentMethod[]
  spaceMemberInvites      SpaceMemberInvite[]
  nonprofitApplications   NonprofitApplication[]

  subscriptions Subscription[] @relation("UserToSubscription")
  spaces        Space[]        @relation("UserSpaces")
  memberOf      SpaceMember[]

  scheduledEvents       ScheduledEvent[]
  scheduledEventInvites ScheduledEventInvite[]
  hostedEventTypes      EventType[]
  hostedSheets          Sheet[]

  calendarConnections     CalendarConnection[]
  conferencingConnections ConferencingConnection[]
  credentials             Credential[]

  // Default destination calendar for new events
  defaultDestinationCalendarId String?           @map("default_destination_calendar_id")
  defaultDestinationCalendar   ProviderCalendar? @relation("UserDefaultDestinationCalendar", fields: [defaultDestinationCalendarId], references: [id], onDelete: SetNull)

  sessions             Session[]
  impersonatedSessions Session[] @relation("ImpersonatedSessions")

  @@index([deletedAt])
  // Supports the orphaned-anonymous-guest cleanup: filters anonymous users by
  // last-seen time before checking they own no resources.
  @@index([isAnonymous, lastSeenAt])
  @@map("users")
}

model Session {
  id             String   @id
  expiresAt      DateTime @map("expires_at")
  token          String
  createdAt      DateTime @default(now()) @map("created_at")
  updatedAt      DateTime @updatedAt @map("updated_at")
  ipAddress      String?  @map("ip_address")
  userAgent      String?  @map("user_agent")
  userId         String   @map("user_id")
  impersonatedBy String?  @map("impersonated_by")

  user               User  @relation(fields: [userId], references: [id], onDelete: Cascade)
  impersonatedByUser User? @relation("ImpersonatedSessions", fields: [impersonatedBy], references: [id])

  @@unique([token])
  @@map("sessions")
}

model Verification {
  id         String   @id
  identifier String   @unique
  value      String
  expiresAt  DateTime @map("expires_at")
  createdAt  DateTime @default(now()) @map("created_at")
  updatedAt  DateTime @default(now()) @updatedAt @map("updated_at")

  @@index([identifier])
  @@map("verifications")
}