Files
sign/packages/prisma/schema.prisma

129 lines
3.1 KiB
Plaintext
Raw Normal View History

2023-01-07 15:10:26 +01:00
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Document {
2023-01-27 20:14:32 +01:00
id Int @id @default(autoincrement())
2023-01-07 15:10:26 +01:00
userId Int
2023-01-27 20:14:32 +01:00
User User @relation(fields: [userId], references: [id], onDelete: Cascade)
2023-01-25 10:16:49 +01:00
title String
2023-01-27 20:14:32 +01:00
status DocumentStatus @default(DRAFT)
2023-01-25 10:16:49 +01:00
document String
2023-01-07 15:10:26 +01:00
Recipient Recipient[]
2023-02-13 19:33:26 +01:00
Field Field[]
}
model Field {
id Int @id @default(autoincrement())
documentId Int
recipientId Int?
type FieldType
page Int
positionX Int @default(0)
positionY Int @default(0)
Document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
Recipient Recipient? @relation(fields: [recipientId], references: [id], onDelete: Cascade)
2023-02-19 12:47:39 +01:00
Signature Signature?
}
model Signature {
id Int @id @default(autoincrement())
created DateTime @default(now())
recipientId Int
fieldId Int @unique
signatureImageAsBase64 String
Recipient Recipient @relation(fields: [recipientId], references: [id], onDelete: Restrict)
Field Field @relation(fields: [fieldId], references: [id], onDelete: Restrict)
2023-01-07 15:10:26 +01:00
}
model Recipient {
id Int @id @default(autoincrement())
documentId Int
2023-02-03 19:57:54 +01:00
email String @db.VarChar(255)
2023-02-03 18:07:43 +01:00
name String @default("") @db.VarChar(255)
token String
2023-01-27 17:21:40 +01:00
readStatus ReadStatus @default(NOT_OPENED)
signingStatus SigningStatus @default(NOT_SIGNED)
sendStatus SendStatus @default(NOT_SENT)
2023-01-07 15:10:26 +01:00
Document Document @relation(fields: [documentId], references: [id], onDelete: Cascade)
2023-02-13 19:33:26 +01:00
Field Field[]
2023-02-19 12:47:39 +01:00
Signature Signature[]
2023-01-07 15:10:26 +01:00
}
model User {
2023-01-10 18:52:04 +01:00
id Int @id @default(autoincrement())
name String?
email String @unique
emailVerified DateTime?
password String?
identityProvider IdentityProvider @default(DOCUMENSO)
accounts Account[]
sessions Session[]
Document Document[]
}
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)
}
2023-02-13 19:33:26 +01:00
enum FieldType {
SIGNATURE
DATE
TEXT
}
2023-01-10 18:52:04 +01:00
enum IdentityProvider {
DOCUMENSO
GOOGLE
2023-01-07 15:10:26 +01:00
}
enum ReadStatus {
NOT_OPENED
OPENED
}
enum SendStatus {
NOT_SENT
SENT
}
enum SigningStatus {
NOT_SIGNED
SIGNED
}
2023-01-27 20:14:32 +01:00
enum DocumentStatus {
DRAFT
PENDING
COMPLETED
}