mirror of
https://github.com/documenso/documenso.git
synced 2025-11-09 20:12:31 +10:00
Fixes #705 --------- Co-authored-by: Lucas Smith <me@lucasjamessmith.me> Co-authored-by: David Nguyen <davidngu28@gmail.com>
324 lines
8.5 KiB
Plaintext
324 lines
8.5 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("NEXT_PRIVATE_DATABASE_URL")
|
|
directUrl = env("NEXT_PRIVATE_DIRECT_DATABASE_URL")
|
|
}
|
|
|
|
enum IdentityProvider {
|
|
DOCUMENSO
|
|
GOOGLE
|
|
}
|
|
|
|
enum Role {
|
|
ADMIN
|
|
USER
|
|
}
|
|
|
|
model User {
|
|
id Int @id @default(autoincrement())
|
|
name String?
|
|
customerId String? @unique
|
|
email String @unique
|
|
emailVerified DateTime?
|
|
password String?
|
|
source String?
|
|
signature String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @default(now()) @updatedAt
|
|
lastSignedIn DateTime @default(now())
|
|
roles Role[] @default([USER])
|
|
identityProvider IdentityProvider @default(DOCUMENSO)
|
|
accounts Account[]
|
|
sessions Session[]
|
|
Document Document[]
|
|
Subscription Subscription[]
|
|
PasswordResetToken PasswordResetToken[]
|
|
twoFactorSecret String?
|
|
twoFactorEnabled Boolean @default(false)
|
|
twoFactorBackupCodes String?
|
|
|
|
VerificationToken VerificationToken[]
|
|
Template Template[]
|
|
securityAuditLogs UserSecurityAuditLog[]
|
|
|
|
@@index([email])
|
|
}
|
|
|
|
enum UserSecurityAuditLogType {
|
|
ACCOUNT_PROFILE_UPDATE
|
|
ACCOUNT_SSO_LINK
|
|
AUTH_2FA_DISABLE
|
|
AUTH_2FA_ENABLE
|
|
PASSWORD_RESET
|
|
PASSWORD_UPDATE
|
|
SIGN_OUT
|
|
SIGN_IN
|
|
SIGN_IN_FAIL
|
|
SIGN_IN_2FA_FAIL
|
|
}
|
|
|
|
model UserSecurityAuditLog {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
createdAt DateTime @default(now())
|
|
type UserSecurityAuditLogType
|
|
userAgent String?
|
|
ipAddress String?
|
|
|
|
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model PasswordResetToken {
|
|
id Int @id @default(autoincrement())
|
|
token String @unique
|
|
createdAt DateTime @default(now())
|
|
expiry DateTime
|
|
userId Int
|
|
User User @relation(fields: [userId], references: [id])
|
|
}
|
|
|
|
model VerificationToken {
|
|
id Int @id @default(autoincrement())
|
|
identifier String
|
|
token String @unique
|
|
expires DateTime
|
|
createdAt DateTime @default(now())
|
|
userId Int
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
enum SubscriptionStatus {
|
|
ACTIVE
|
|
PAST_DUE
|
|
INACTIVE
|
|
}
|
|
|
|
model Subscription {
|
|
id Int @id @default(autoincrement())
|
|
status SubscriptionStatus @default(INACTIVE)
|
|
planId String @unique
|
|
priceId String
|
|
periodEnd DateTime?
|
|
userId Int
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
cancelAtPeriodEnd Boolean @default(false)
|
|
|
|
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([userId])
|
|
}
|
|
|
|
model Account {
|
|
id String @id @default(cuid())
|
|
userId Int
|
|
type String
|
|
provider String
|
|
providerAccountId String
|
|
refresh_token String? @db.Text
|
|
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])
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
sessionToken String @unique
|
|
userId Int
|
|
expires DateTime
|
|
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
enum DocumentStatus {
|
|
DRAFT
|
|
PENDING
|
|
COMPLETED
|
|
}
|
|
|
|
model Document {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
title String
|
|
status DocumentStatus @default(DRAFT)
|
|
Recipient Recipient[]
|
|
Field Field[]
|
|
ShareLink DocumentShareLink[]
|
|
documentDataId String
|
|
documentData DocumentData @relation(fields: [documentDataId], references: [id], onDelete: Cascade)
|
|
documentMeta DocumentMeta?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @default(now()) @updatedAt
|
|
completedAt DateTime?
|
|
deletedAt DateTime?
|
|
|
|
@@unique([documentDataId])
|
|
@@index([userId])
|
|
@@index([status])
|
|
}
|
|
|
|
enum DocumentDataType {
|
|
S3_PATH
|
|
BYTES
|
|
BYTES_64
|
|
}
|
|
|
|
model DocumentData {
|
|
id String @id @default(cuid())
|
|
type DocumentDataType
|
|
data String
|
|
initialData String
|
|
Document Document?
|
|
Template Template?
|
|
}
|
|
|
|
model DocumentMeta {
|
|
id String @id @default(cuid())
|
|
subject String?
|
|
message String?
|
|
timezone String? @default("Etc/UTC") @db.Text
|
|
password String?
|
|
dateFormat String? @default("yyyy-MM-dd hh:mm a") @db.Text
|
|
documentId Int @unique
|
|
document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
enum ReadStatus {
|
|
NOT_OPENED
|
|
OPENED
|
|
}
|
|
|
|
enum SendStatus {
|
|
NOT_SENT
|
|
SENT
|
|
}
|
|
|
|
enum SigningStatus {
|
|
NOT_SIGNED
|
|
SIGNED
|
|
}
|
|
|
|
enum RecipientRole {
|
|
CC
|
|
SIGNER
|
|
VIEWER
|
|
APPROVER
|
|
}
|
|
|
|
model Recipient {
|
|
id Int @id @default(autoincrement())
|
|
documentId Int?
|
|
templateId Int?
|
|
email String @db.VarChar(255)
|
|
name String @default("") @db.VarChar(255)
|
|
token String
|
|
expired DateTime?
|
|
signedAt DateTime?
|
|
role RecipientRole @default(SIGNER)
|
|
readStatus ReadStatus @default(NOT_OPENED)
|
|
signingStatus SigningStatus @default(NOT_SIGNED)
|
|
sendStatus SendStatus @default(NOT_SENT)
|
|
Document Document? @relation(fields: [documentId], references: [id], onDelete: Cascade)
|
|
Template Template? @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
|
Field Field[]
|
|
Signature Signature[]
|
|
|
|
@@unique([documentId, email])
|
|
@@unique([templateId, email])
|
|
@@index([documentId])
|
|
@@index([templateId])
|
|
@@index([token])
|
|
}
|
|
|
|
enum FieldType {
|
|
SIGNATURE
|
|
FREE_SIGNATURE
|
|
NAME
|
|
EMAIL
|
|
DATE
|
|
TEXT
|
|
}
|
|
|
|
model Field {
|
|
id Int @id @default(autoincrement())
|
|
documentId Int?
|
|
templateId Int?
|
|
recipientId Int?
|
|
type FieldType
|
|
page Int
|
|
positionX Decimal @default(0)
|
|
positionY Decimal @default(0)
|
|
width Decimal @default(-1)
|
|
height Decimal @default(-1)
|
|
customText String
|
|
inserted Boolean
|
|
Document Document? @relation(fields: [documentId], references: [id], onDelete: Cascade)
|
|
Template Template? @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
|
Recipient Recipient? @relation(fields: [recipientId], references: [id])
|
|
Signature Signature?
|
|
|
|
@@index([documentId])
|
|
@@index([templateId])
|
|
@@index([recipientId])
|
|
}
|
|
|
|
model Signature {
|
|
id Int @id @default(autoincrement())
|
|
created DateTime @default(now())
|
|
recipientId Int
|
|
fieldId Int @unique
|
|
signatureImageAsBase64 String?
|
|
typedSignature String?
|
|
|
|
Recipient Recipient @relation(fields: [recipientId], references: [id], onDelete: Cascade)
|
|
Field Field @relation(fields: [fieldId], references: [id], onDelete: Restrict)
|
|
|
|
@@index([recipientId])
|
|
}
|
|
|
|
model DocumentShareLink {
|
|
id Int @id @default(autoincrement())
|
|
email String
|
|
slug String @unique
|
|
documentId Int
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([documentId, email])
|
|
}
|
|
|
|
enum TemplateType {
|
|
PUBLIC
|
|
PRIVATE
|
|
}
|
|
|
|
model Template {
|
|
id Int @id @default(autoincrement())
|
|
type TemplateType @default(PRIVATE)
|
|
title String
|
|
userId Int
|
|
templateDocumentDataId String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @default(now()) @updatedAt
|
|
|
|
templateDocumentData DocumentData @relation(fields: [templateDocumentDataId], references: [id], onDelete: Cascade)
|
|
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
Recipient Recipient[]
|
|
Field Field[]
|
|
|
|
@@unique([templateDocumentDataId])
|
|
}
|