143 lines
5.1 KiB
Plaintext
143 lines
5.1 KiB
Plaintext
// Auth (Better Auth) - required tables
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
name String
|
|
email String @unique
|
|
emailVerified Boolean @default(false) @map("email_verified")
|
|
image String?
|
|
onboardingCompleted Boolean @default(false) @map("onboarding_completed")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
accounts Account[]
|
|
sessions Session[]
|
|
passkeys Passkey[]
|
|
groupsMember GroupMember[]
|
|
groupsOwner Group[] @relation("OwnerGroups")
|
|
orgMemberships Member[]
|
|
orgInvitations Invitation[] @relation("InvitedBy")
|
|
waitlist WaitlistEntry[]
|
|
merchantAccount MerchantAccount?
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model Account {
|
|
id String @id @default(cuid())
|
|
userId String @map("user_id")
|
|
providerId String @map("provider_id")
|
|
accountId String @map("account_id")
|
|
issuer String
|
|
accessToken String? @map("access_token")
|
|
refreshToken String? @map("refresh_token")
|
|
idToken String? @map("id_token")
|
|
accessTokenExpiresAt DateTime? @map("access_token_expires_at")
|
|
refreshTokenExpiresAt DateTime? @map("refresh_token_expires_at")
|
|
scope String?
|
|
password String?
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "accounts_userId_fkey")
|
|
|
|
@@unique([issuer, accountId], map: "accounts_issuer_accountId_key")
|
|
@@index([userId], map: "accounts_userId_idx")
|
|
@@map("accounts")
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
userId String @map("user_id")
|
|
token String @unique
|
|
expiresAt DateTime @map("expires_at")
|
|
ipAddress String? @map("ip_address")
|
|
userAgent String? @map("user_agent")
|
|
activeOrganizationId String? @map("active_organization_id")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "sessions_userId_fkey")
|
|
|
|
@@map("sessions")
|
|
}
|
|
|
|
model Verification {
|
|
id String @id @default(cuid())
|
|
identifier String
|
|
value String
|
|
expiresAt DateTime @map("expires_at")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@unique([identifier, value])
|
|
@@map("verifications")
|
|
}
|
|
|
|
// Better Auth - Organization plugin
|
|
model Organization {
|
|
id String @id @default(cuid())
|
|
name String
|
|
slug String @unique
|
|
logo String?
|
|
metadata Json?
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
members Member[]
|
|
invitations Invitation[]
|
|
|
|
@@map("organizations")
|
|
}
|
|
|
|
model Member {
|
|
id String @id @default(cuid())
|
|
organizationId String @map("organization_id")
|
|
userId String @map("user_id")
|
|
role String @default("member")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, map: "members_organizationId_fkey")
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "members_userId_fkey")
|
|
|
|
@@unique([organizationId, userId], map: "members_organizationId_userId_key")
|
|
@@map("members")
|
|
}
|
|
|
|
model Invitation {
|
|
id String @id @default(cuid())
|
|
organizationId String @map("organization_id")
|
|
email String
|
|
role String
|
|
status String @default("pending")
|
|
inviterId String @map("inviter_id")
|
|
expiresAt DateTime @map("expires_at")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, map: "invitations_organizationId_fkey")
|
|
inviter User @relation("InvitedBy", fields: [inviterId], references: [id], onDelete: Cascade, map: "invitations_inviterId_fkey")
|
|
|
|
@@index([organizationId], map: "invitations_organizationId_idx")
|
|
@@map("invitations")
|
|
}
|
|
|
|
// Better Auth - Passkey plugin
|
|
model Passkey {
|
|
id String @id @default(cuid())
|
|
name String?
|
|
publicKey String @map("public_key")
|
|
credentialID String @unique(map: "passkeys_credentialID_key") @map("credential_id")
|
|
userId String @map("user_id")
|
|
counter Int
|
|
deviceType String @map("device_type")
|
|
backedUp Boolean @map("backed_up")
|
|
transports String?
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
aaguid String?
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade, map: "passkeys_userId_fkey")
|
|
|
|
@@index([userId], map: "passkeys_userId_idx")
|
|
@@map("passkeys")
|
|
}
|