Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

2.4 KB
Raw Blame
datasource db {
  provider     = "mysql"
  url          = env("DATABASE_URL")
  relationMode = "prisma"
}

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

model User {
  id            String    @id @default(cuid())
  name          String?
  email         String?   @unique
  emailVerified DateTime?
  image         String?
  isMachine     Boolean   @default(false)
  createdAt     DateTime  @default(now())

  // password & security fields
  passwordHash         String?
  invalidLoginAttempts Int       @default(0)
  lockedAt             DateTime?

  // user preferences
  defaultWorkspace String? // slug of the user's default workspace

  // internal fields
  source   String? // where the user came from
  sentMail Boolean @default(false)

  // relational data
  accounts                Account[]
  sessions                Session[]
  notificationPreferences UserNotificationPreferences?
  projects                ProjectUsers[]
  links                   Link[]
  dashboards              Dashboard[]
  tokens                  Token[]
  restrictedTokens        RestrictedToken[]
  oAuthCodes              OAuthCode[]
  integrations            Integration[] // Integrations user created in their workspace
  installedIntegrations   InstalledIntegration[] // Integrations user installed in their workspace
  folders                 FolderUser[]
  folderAccessRequests    FolderAccessRequest[]
  utmTemplates            UtmTemplate[]

  @@index(createdAt)
  @@index(defaultWorkspace)
  @@index(source)
  @@index(sentMail)
}

model Account {
  id                       String  @id @default(cuid())
  userId                   String
  type                     String
  provider                 String
  providerAccountId        String
  refresh_token            String? @db.Text
  refresh_token_expires_in Int?
  access_token             String? @db.Text
  expires_at               Int?
  token_type               String?
  scope                    String?
  id_token                 String? @db.Text
  session_state            String?

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

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

model Session {
  id           String   @id @default(cuid())
  sessionToken String   @unique
  userId       String
  expires      DateTime
  user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@index([userId])
}