elliottchong

prisma migration

Feb 7th, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.05 KB | None | 0 0
  1. generator client {
  2. provider = "prisma-client-js"
  3. }
  4.  
  5. datasource db {
  6. provider = "postgresql"
  7. url = env("DATABASE_URL")
  8. }
  9.  
  10. model User {
  11. id String @id
  12. email String @unique
  13. firstName String
  14. lastName String
  15. role UserRole @default(applicant)
  16. createdAt DateTime @default(now())
  17. updatedAt DateTime @default(now()) @updatedAt
  18. devId String? @unique
  19. hashedPassword String?
  20. emailVerified DateTime?
  21. Account Account[]
  22. applications Application[] @relation("ApplicationToUser")
  23. conversations Conversation[]
  24. conversationSessionLog ConversationSessionLog[]
  25. ConversationsToUsers ConversationsToUsers[]
  26. messages Message[]
  27. Session Session[]
  28. WorkflowSchema WorkflowSchema[]
  29. authorizedOrganizationsStatuses OrganizationStatus[] @relation("AuthorizedUsers")
  30. Chore Chore[] @relation("ChoreToUser")
  31. ChoreTrigger ChoreTrigger[] @relation("ChoreTriggerToUser")
  32. organizations Organization[] @relation("OrganizationToUser")
  33. }
  34.  
  35. model TempUserHashPassword {
  36. id String @id @default(cuid())
  37. createdAt DateTime @default(now())
  38. updatedAt DateTime @default(now())
  39. hashedPassword String
  40. userId String
  41. }
  42.  
  43. model Message {
  44. id String @id @default(cuid())
  45. text String
  46. timestamp DateTime @default(now())
  47. messageType MessageType
  48. aiThoughtProcess String?
  49. approvedById String?
  50. approvedAt DateTime?
  51. conversationId String
  52. uploadRequired Boolean @default(false)
  53. systemMessage String?
  54. subject String? @default("")
  55. attachments String[] @default([])
  56. source Company?
  57. sourceId String?
  58. contactId String?
  59. approvedBy User? @relation(fields: [approvedById], references: [id])
  60. contact Contact? @relation(fields: [contactId], references: [id])
  61. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  62. }
  63.  
  64. model ClientFile {
  65. id String @id @default(cuid())
  66. createdAt DateTime @default(now())
  67. updatedAt DateTime @default(now()) @updatedAt
  68. requiredName String
  69. uploadedName String?
  70. conversationId String
  71. url String?
  72. previewUrl String?
  73. status ClientFileStatus @default(pending)
  74. Description String?
  75. RejectionReasoning String?
  76. Visibility Visibility @default(private)
  77. fileType String?
  78. statusId String?
  79. documentType DocumentType @default(OTHER)
  80. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  81. extractedValues ExtractedValue[]
  82. }
  83.  
  84. model ExtractedValue {
  85. id String @id @default(cuid())
  86. name String
  87. createdAt DateTime @default(now())
  88. updatedAt DateTime @default(now()) @updatedAt
  89. value String
  90. clientFileId String
  91. displayName String
  92. clientFile ClientFile @relation(fields: [clientFileId], references: [id], onDelete: Cascade)
  93. }
  94.  
  95. model Client {
  96. id String @id @default(cuid())
  97. createdAt DateTime @default(now())
  98. updatedAt DateTime @default(now()) @updatedAt
  99. name String?
  100. organizationId String
  101. activeContactId String?
  102. caseId String?
  103. Case Case?
  104. organization Organization @relation(fields: [organizationId], references: [id])
  105. contacts Contact[]
  106. conversations Conversation[] @relation("conversationToClient")
  107. }
  108.  
  109. model Contact {
  110. id String @id @default(cuid())
  111. createdAt DateTime @default(now())
  112. updatedAt DateTime @default(now()) @updatedAt
  113. detail String
  114. mode CommunicationMedium
  115. clientId String
  116. creationId String?
  117. Client Client @relation(fields: [clientId], references: [id])
  118. messages Message[]
  119. }
  120.  
  121. model Account {
  122. id String @id
  123. userId String
  124. type String
  125. provider String
  126. providerAccountId String
  127. refresh_token String?
  128. access_token String?
  129. expires_at Int
  130. token_type String?
  131. scope String?
  132. id_token String?
  133. session_state String?
  134. User User @relation(fields: [userId], references: [id], onDelete: Cascade)
  135.  
  136. @@unique([provider, providerAccountId])
  137. }
  138.  
  139. model LandingContactForm {
  140. id String @id @default(cuid())
  141. createdAt DateTime @default(now())
  142. updatedAt DateTime @default(now())
  143. email String
  144. name String?
  145. company String?
  146. message String?
  147. }
  148.  
  149. model EmailVerification {
  150. id String @id
  151. expires DateTime
  152. code String @unique
  153. userId String @unique
  154. }
  155.  
  156. model Session {
  157. id String @id
  158. sessionToken String @unique
  159. userId String
  160. expires DateTime
  161. User User @relation(fields: [userId], references: [id], onDelete: Cascade)
  162. }
  163.  
  164. model Case {
  165. id String @id @default(cuid())
  166. createdAt DateTime @default(now())
  167. updatedAt DateTime @default(now()) @updatedAt
  168. organizationId String
  169. aiTimestampLock DateTime @default(now())
  170. creationId String?
  171. activeConversationId String?
  172. clientId String? @unique
  173. role UserRole @default(lead)
  174. client Client? @relation(fields: [clientId], references: [id])
  175. organization Organization @relation(fields: [organizationId], references: [id])
  176. FunctionTask FunctionTask[]
  177. Memory Memory[]
  178. conversations Conversation[] @relation("CaseToConversation")
  179. }
  180.  
  181. model Conversation {
  182. id String @id @default(cuid())
  183. createdAt DateTime @default(now())
  184. updatedAt DateTime @default(now()) @updatedAt
  185. purpose String @default("")
  186. organizationId String
  187. humanOperatorId String?
  188. productId String
  189. initial_delay Int @default(30)
  190. actionStatus ActionStatus @default(PROCESSING)
  191. conversationStatusUpdatedAt DateTime?
  192. organizationStatusId String?
  193. productStatusId String?
  194. applicationId String?
  195. aiTimestampLock DateTime @default(now())
  196. conversationStateId String?
  197. metadata Json?
  198. rating Int?
  199. application Application?
  200. attributeValues AttributeValue[]
  201. chores Chore[]
  202. ClientFact ClientFact[]
  203. clientFiles ClientFile[]
  204. humanOperator User? @relation(fields: [humanOperatorId], references: [id])
  205. organization Organization @relation(fields: [organizationId], references: [id])
  206. organizationStatus OrganizationStatus? @relation(fields: [organizationStatusId], references: [id])
  207. product Product @relation(fields: [productId], references: [id])
  208. ProductStatus ProductStatus? @relation(fields: [productStatusId], references: [id])
  209. ConversationCheck ConversationCheck[]
  210. classifications ConversationClassfication[]
  211. ConversationDisplay ConversationDisplay[]
  212. conversationSessionLog ConversationSessionLog[]
  213. ConversationsToUsers ConversationsToUsers[]
  214. FunctionTask FunctionTask[]
  215. Memory Memory[]
  216. messages Message[]
  217. Reminders Reminders[]
  218. workflowFieldValues WorkflowFieldValues[]
  219. workflowSubmissions WorkflowSubmission[]
  220. cases Case[] @relation("CaseToConversation")
  221. clients Client[] @relation("conversationToClient")
  222. }
  223.  
  224. model ConversationSessionLog {
  225. id String @id @default(cuid())
  226. createdAt DateTime @default(now())
  227. updatedAt DateTime @default(now()) @updatedAt
  228. userId String
  229. conversationId String
  230. active Boolean @default(true)
  231. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  232. user User @relation(fields: [userId], references: [id])
  233. }
  234.  
  235. model ConversationsToUsers {
  236. id String @id @default(cuid())
  237. createdAt DateTime @default(now())
  238. updatedAt DateTime @default(now()) @updatedAt
  239. conversationId String
  240. userId String
  241. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  242. user User @relation(fields: [userId], references: [id], onDelete: Cascade)
  243.  
  244. @@unique([conversationId, userId])
  245. }
  246.  
  247. model ConversationCheck {
  248. id String @id @default(cuid())
  249. createdAt DateTime @default(now())
  250. updatedAt DateTime @default(now()) @updatedAt
  251. conversationId String
  252. value String?
  253. status ConversationCheckStatus @default(PENDING)
  254. description String?
  255. fieldName String
  256. formType OrganizationCheckFormType @default(TEXTAREA)
  257. options String?
  258. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  259.  
  260. @@unique([conversationId, fieldName])
  261. }
  262.  
  263. model OrganizationDisplay {
  264. id String @id @default(cuid())
  265. createdAt DateTime @default(now())
  266. updatedAt DateTime @default(now()) @updatedAt
  267. organizationId String
  268. fieldName String
  269. description String?
  270. ConversationDisplay ConversationDisplay[]
  271. organization Organization @relation(fields: [organizationId], references: [id])
  272. }
  273.  
  274. model ConversationDisplay {
  275. id String @id @default(cuid())
  276. createdAt DateTime @default(now())
  277. updatedAt DateTime @default(now()) @updatedAt
  278. conversationId String
  279. organizationDisplayId String
  280. value String?
  281. status displayStatus @default(unknown)
  282. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  283. organizationDisplay OrganizationDisplay @relation(fields: [organizationDisplayId], references: [id], onDelete: Cascade)
  284. }
  285.  
  286. model Organization {
  287. id String @id @default(cuid())
  288. name String
  289. apiKey String
  290. createdAt DateTime @default(now())
  291. updatedAt DateTime @default(now()) @updatedAt
  292. organizationEmail String?
  293. organizationEmailToken Json?
  294. organizationHistoryId String?
  295. description String?
  296. accentColor String?
  297. bigLogoUrl String?
  298. mainColor String?
  299. smallLogoUrl String?
  300. websiteUrl String?
  301. defaultProductId String? @unique
  302. applications Application[] @relation("OrganizationToApplication")
  303. Case Case[]
  304. Chore Chore[]
  305. Client Client[]
  306. conversations Conversation[]
  307. Document Document[]
  308. defaultProduct Product? @relation("DefaultProduct", fields: [defaultProductId], references: [id])
  309. OrganizationDisplay OrganizationDisplay[]
  310. organizationStatuses OrganizationStatus[]
  311. products Product[] @relation("OrganizationProducts")
  312. workflow Workflow[]
  313. users User[] @relation("OrganizationToUser")
  314. }
  315.  
  316. model Product {
  317. organizationId String
  318. id String @id @default(cuid())
  319. name String
  320. description String
  321. agentId String
  322. createdAt DateTime @default(now())
  323. updatedAt DateTime? @updatedAt
  324. Attribute Attribute[]
  325. conversations Conversation[]
  326. Organization Organization? @relation("DefaultProduct")
  327. agent Agent @relation(fields: [agentId], references: [id])
  328. organization Organization @relation("OrganizationProducts", fields: [organizationId], references: [id])
  329. classicications ProductClassification[]
  330. productStatuses ProductStatus[]
  331. WorkflowSchema WorkflowSchema[]
  332. entities Entity[] @relation("EntityToProduct")
  333. }
  334.  
  335. model OrganizationStatus {
  336. id String @id @default(cuid())
  337. createdAt DateTime @default(now())
  338. updatedAt DateTime @default(now()) @updatedAt
  339. name String
  340. description String?
  341. organizationId String
  342. isPublic Boolean @default(false)
  343. order Int @default(0)
  344. publicDescription String?
  345. Conversation Conversation[]
  346. organization Organization @relation(fields: [organizationId], references: [id])
  347. authorizedUsers User[] @relation("AuthorizedUsers")
  348. }
  349.  
  350. model FileStatusTrigger {
  351. id String @id @default(cuid())
  352. createdAt DateTime @default(now())
  353. requiredFileName String
  354. description String?
  355. requiredFileVisibility Visibility
  356. productStatusId String
  357. documentType DocumentType @default(OTHER)
  358. productStatus ProductStatus @relation(fields: [productStatusId], references: [id])
  359. }
  360.  
  361. model WorkflowTrigger {
  362. id String @id @default(cuid())
  363. createdAt DateTime @default(now())
  364. updatedAt DateTime @default(now()) @updatedAt
  365. workflowId String
  366. productStatusId String
  367. productStatus ProductStatus @relation(fields: [productStatusId], references: [id])
  368. workflow Workflow @relation(fields: [workflowId], references: [id])
  369. }
  370.  
  371. model CheckStatusTrigger {
  372. id String @id @default(cuid())
  373. createdAt DateTime @default(now())
  374. fieldName String
  375. description String?
  376. formType OrganizationCheckFormType
  377. options String?
  378. productStatusId String
  379. productStatus ProductStatus @relation(fields: [productStatusId], references: [id])
  380. }
  381.  
  382. model ProductClassification {
  383. id String @id @default(cuid())
  384. createdAt DateTime @default(now())
  385. updatedAt DateTime @default(now()) @updatedAt
  386. name String
  387. description String?
  388. condition String?
  389. productId String
  390. color String @default("#3b82f7")
  391. icon String?
  392. conversationClassifications ConversationClassfication[]
  393. product Product @relation(fields: [productId], references: [id])
  394. }
  395.  
  396. model ConversationClassfication {
  397. id String @id @default(cuid())
  398. createdAt DateTime @default(now())
  399. updatedAt DateTime @default(now()) @updatedAt
  400. conversationId String
  401. classficationId String
  402. classfication ProductClassification @relation(fields: [classficationId], references: [id])
  403. conversation Conversation @relation(fields: [conversationId], references: [id])
  404. }
  405.  
  406. model ProductStatus {
  407. id String @id @default(cuid())
  408. createdAt DateTime @default(now())
  409. updatedAt DateTime @updatedAt
  410. name String
  411. description String?
  412. isPublic Boolean @default(false)
  413. order Int @default(0)
  414. publicDescription String?
  415. productId String
  416. aiInstructions String? @default("")
  417. initial Boolean @default(false)
  418. CheckStatusTrigger CheckStatusTrigger[]
  419. ChoreTrigger ChoreTrigger[]
  420. factStatusTriggers ClientFactTrigger[]
  421. Conversation Conversation[]
  422. fileStatusTriggers FileStatusTrigger[]
  423. Product Product @relation(fields: [productId], references: [id])
  424. workflowTriggers WorkflowTrigger[]
  425. workflow Workflow[] @relation("ProductStatusToWorkflow")
  426. }
  427.  
  428. model Agent {
  429. id String @id @default(cuid())
  430. name String
  431. agentType AgentType
  432. agentVersion String
  433. description String
  434. createdAt DateTime @default(now())
  435. updatedAt DateTime @default(now()) @updatedAt
  436. imageUrl String?
  437. products Product[]
  438. }
  439.  
  440. model Application {
  441. id String @id @default(cuid())
  442. createdAt DateTime @default(now())
  443. updatedAt DateTime @default(now()) @updatedAt
  444. businessName String
  445. industry String
  446. creditAmount Float
  447. loanPurpose String
  448. businessAddress String
  449. businessCity String?
  450. businessState String?
  451. businessZipCode String?
  452. ownerMaritalStatus String?
  453. ssn String
  454. phoneNo String
  455. ownershipPercentage Float
  456. numberOfOwners Int?
  457. ownerAddress String
  458. ownerCity String?
  459. ownerState String?
  460. ownerZipCode String?
  461. organizationId String?
  462. userId String?
  463. businessWebsite String?
  464. ownerIsActiveInMilitary Boolean?
  465. taxPayerIdentificationNumber String?
  466. conversationId String? @unique
  467. emailAddress String?
  468. fullYearsIncorporated Int @default(0)
  469. lastYearRevenue Float @default(0)
  470. ownerFirstName String
  471. ownerLastName String
  472. pastBankruptcy Boolean?
  473. womenOwned Boolean?
  474. yearBeforeRevenue Float @default(0)
  475. incorporationDate DateTime?
  476. businessType String?
  477. conversation Conversation? @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  478. organization Organization? @relation("OrganizationToApplication", fields: [organizationId], references: [id])
  479. user User? @relation("ApplicationToUser", fields: [userId], references: [id])
  480. }
  481.  
  482. model Reminders {
  483. id String @id
  484. createdAt DateTime @default(now())
  485. updatedAt DateTime? @default(now()) @updatedAt
  486. conversationId String
  487. duration Int @default(0)
  488. lastLeadEventDate DateTime @default(now())
  489. triggerDate DateTime
  490. type ReminderType @default(automatic)
  491. Conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  492. }
  493.  
  494. model FunctionReminder {
  495. id String @id
  496. triggerDate DateTime
  497. }
  498.  
  499. model ClientFact {
  500. id String @id @default(cuid())
  501. createdAt DateTime @default(now())
  502. updatedAt DateTime @default(now()) @updatedAt
  503. question String
  504. conversationId String
  505. RejectionReasoning String?
  506. Description String?
  507. fact String?
  508. statusId String?
  509. clientFactStatus ClientFileStatus @default(pending)
  510. Conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  511. }
  512.  
  513. model ClientFactTrigger {
  514. id String @id @default(cuid())
  515. createdAt DateTime @default(now())
  516. updatedAt DateTime @default(now()) @updatedAt
  517. question String
  518. description String @default("")
  519. productStatusId String
  520. productStatus ProductStatus @relation(fields: [productStatusId], references: [id])
  521. }
  522.  
  523. model Workflow {
  524. id String @id @default(cuid())
  525. createdAt DateTime @default(now())
  526. updatedAt DateTime @default(now()) @updatedAt
  527. description String?
  528. url String?
  529. internal Boolean @default(false)
  530. name String?
  531. organizationId String
  532. slug String?
  533. type WorkflowType?
  534. organization Organization @relation(fields: [organizationId], references: [id])
  535. triggers WorkflowTrigger[]
  536. statuses ProductStatus[] @relation("ProductStatusToWorkflow")
  537. }
  538.  
  539. model WorkflowFields {
  540. id String @id(map: "WWorkflowField_pkey") @default(cuid())
  541. createdAt DateTime @default(now())
  542. updatedAt DateTime @default(now()) @updatedAt
  543. name String
  544. description String?
  545. order Int
  546. dataType FormFieldType
  547. required Boolean @default(true)
  548. isInput Boolean @default(false)
  549. workflowSchemaId String
  550. options String?
  551. codeName String?
  552. entityFieldId String?
  553. workflowCardId String?
  554. orderWithinCard Int @default(0)
  555. validation String?
  556. values WorkflowFieldValues[]
  557. tenantEntityField EntityField? @relation(fields: [entityFieldId], references: [id], map: "WWorkflowField_entityFieldId_fkey")
  558. workflowCard WorkflowCard? @relation(fields: [workflowCardId], references: [id], map: "WWorkflowField_workflowCardId_fkey")
  559. workflowSchema WorkflowSchema @relation(fields: [workflowSchemaId], references: [id], onDelete: Cascade, map: "WWorkflowField_workflowSchemaId_fkey")
  560.  
  561. @@unique([workflowSchemaId, codeName], map: "WWorkflowField_workflowSchemaId_codeName_key")
  562. }
  563.  
  564. model WorkflowFieldValues {
  565. id String @id @default(cuid())
  566. createdAt DateTime @default(now())
  567. updatedAt DateTime @default(now()) @updatedAt
  568. value String?
  569. workflowFieldId String
  570. conversationId String
  571. pinned Boolean @default(false)
  572. status displayStatus @default(unknown)
  573. Conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  574. WorkflowField WorkflowFields @relation(fields: [workflowFieldId], references: [id], onDelete: Cascade)
  575. }
  576.  
  577. model Attribute {
  578. id String @id @default(uuid())
  579. createdAt DateTime @default(now())
  580. updatedAt DateTime @default(now()) @updatedAt
  581. name String
  582. type String
  583. description String?
  584. enumOptions String[]
  585. dataType String
  586. optional Boolean @default(false)
  587. placeholder String?
  588. displayName String?
  589. productId String?
  590. product Product? @relation(fields: [productId], references: [id])
  591. values AttributeValue[]
  592. }
  593.  
  594. model AttributeValue {
  595. id String @id @default(uuid())
  596. createdAt DateTime @default(now())
  597. updatedAt DateTime @default(now()) @updatedAt
  598. value String?
  599. attributeId String
  600. conversationId String
  601. status displayStatus @default(unknown)
  602. pinned Boolean @default(false)
  603. attribute Attribute @relation(fields: [attributeId], references: [id])
  604. conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  605.  
  606. @@unique([attributeId, conversationId])
  607. }
  608.  
  609. model Function {
  610. id String @id @default(cuid())
  611. createdAt DateTime @default(now())
  612. updatedAt DateTime @default(now()) @updatedAt
  613. name String
  614. description String
  615. type FunctionType @default(query)
  616. ActiveFunction ActiveFunction[]
  617. arguments FunctionArgument[]
  618. FunctionAction FunctionAction[] @relation("PossibleFollowingFunctions")
  619. }
  620.  
  621. model FunctionArgument {
  622. id String @id @default(cuid())
  623. createdAt DateTime @default(now())
  624. updatedAt DateTime @default(now()) @updatedAt
  625. name String
  626. description String
  627. dataType String
  628. optional Boolean @default(false)
  629. enumOptions String[] @default([])
  630. functionId String
  631. Function Function @relation(fields: [functionId], references: [id], onDelete: Cascade)
  632. FunctionArgumentValue FunctionArgumentValue[]
  633. }
  634.  
  635. model ActiveFunction {
  636. id String @id @default(cuid())
  637. createdAt DateTime @default(now())
  638. updatedAt DateTime @default(now())
  639. functionId String
  640. Function Function @relation(fields: [functionId], references: [id])
  641. FunctionAction FunctionAction[]
  642. }
  643.  
  644. model FunctionAction {
  645. id String @id @default(cuid())
  646. createdAt DateTime @default(now())
  647. updatedAt DateTime @default(now())
  648. thought String @default("")
  649. HILDecision HILDecision @default(PENDING)
  650. order Int @default(0)
  651. taskId String
  652. activeFunctionId String
  653. systemMessage String @default("")
  654. status FunctionActionStatus @default(pending)
  655. metadata Json?
  656. ActiveFunction ActiveFunction @relation(fields: [activeFunctionId], references: [id])
  657. FunctionTask FunctionTask @relation(fields: [taskId], references: [id])
  658. FunctionArgumentValue FunctionArgumentValue[]
  659. possibleFollowingFunctions Function[] @relation("PossibleFollowingFunctions")
  660. }
  661.  
  662. model FunctionArgumentValue {
  663. id String @id @default(cuid())
  664. createdAt DateTime @default(now())
  665. updatedAt DateTime @default(now())
  666. value String?
  667. actionId String
  668. argumentId String
  669. FunctionAction FunctionAction @relation(fields: [actionId], references: [id], onDelete: Cascade)
  670. FunctionArgument FunctionArgument @relation(fields: [argumentId], references: [id])
  671.  
  672. @@unique([actionId, argumentId])
  673. }
  674.  
  675. model FunctionTask {
  676. id String @id @default(cuid())
  677. createdAt DateTime @default(now())
  678. updatedAt DateTime @default(now())
  679. completed Boolean @default(false)
  680. conversationId String?
  681. caseId String?
  682. typeMetadata Json?
  683. type TaskType @default(action)
  684. FunctionAction FunctionAction[]
  685. Case Case? @relation(fields: [caseId], references: [id])
  686. Conversation Conversation? @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  687. memories Memory[] @relation("FunctionTaskToMemory")
  688. }
  689.  
  690. model Memory {
  691. id String @id @default(cuid())
  692. createdAt DateTime @default(now())
  693. updatedAt DateTime @default(now())
  694. type MemoryType
  695. value String
  696. conversationId String?
  697. hierarchy Hierarchy
  698. role UserRole @default(lead)
  699. caseId String?
  700. Case Case? @relation(fields: [caseId], references: [id])
  701. Conversation Conversation? @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  702. tasks FunctionTask[] @relation("FunctionTaskToMemory")
  703. }
  704.  
  705. model Log {
  706. id String @id @default(cuid())
  707. createdAt DateTime @default(now())
  708. updatedAt DateTime @default(now())
  709. message String
  710. }
  711.  
  712. model Chore {
  713. id String @id @default(cuid())
  714. createdAt DateTime @default(now())
  715. updatedAt DateTime @default(now())
  716. description String
  717. organizationId String
  718. conversationId String
  719. isComplete Boolean @default(false)
  720. completedAt DateTime?
  721. Conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  722. Organization Organization @relation(fields: [organizationId], references: [id])
  723. users User[] @relation("ChoreToUser")
  724.  
  725. @@index([isComplete, conversationId])
  726. }
  727.  
  728. model Document {
  729. id Int @id @default(autoincrement())
  730. organizationId String
  731. title String
  732. status DocumentStatus @default(DRAFT)
  733. createdAt DateTime @default(now())
  734. updatedAt DateTime @default(now())
  735. s3url String
  736. completedAt DateTime?
  737. deletedAt DateTime?
  738. Organization Organization @relation(fields: [organizationId], references: [id])
  739. Field Field[]
  740. Recipient Recipient[]
  741. }
  742.  
  743. model Field {
  744. id Int @id @default(autoincrement())
  745. documentId Int?
  746. type FieldType
  747. page Int
  748. positionX Decimal @default(0)
  749. positionY Decimal @default(0)
  750. width Decimal @default(-1)
  751. height Decimal @default(-1)
  752. customText String?
  753. inserted Boolean
  754. recipientId Int?
  755. Document Document? @relation(fields: [documentId], references: [id], onDelete: Cascade)
  756. Recipient Recipient? @relation(fields: [recipientId], references: [id])
  757. Signature Signature?
  758.  
  759. @@index([documentId])
  760. }
  761.  
  762. model ChoreTrigger {
  763. id String @id(map: "choretrigger_pk")
  764. createdAt DateTime @default(now())
  765. productStatusId String
  766. description String
  767. productStatus ProductStatus @relation(fields: [productStatusId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "choretrigger_productstatus_id_fk")
  768. users User[] @relation("ChoreTriggerToUser")
  769. }
  770.  
  771. model WorkflowCard {
  772. id String @id @default(cuid())
  773. createdAt DateTime @default(now())
  774. updatedAt DateTime @default(now())
  775. order Int @default(0)
  776. workflowSchemaId String
  777. name String
  778. getNextCard String?
  779. codeName String?
  780. isFirstCard Boolean @default(false)
  781. workflowContainerId String?
  782. workflowContainer WorkflowContainer? @relation(fields: [workflowContainerId], references: [id])
  783. workflowSchema WorkflowSchema @relation(fields: [workflowSchemaId], references: [id], onDelete: Cascade)
  784. workflowFields WorkflowFields[]
  785.  
  786. @@unique([workflowSchemaId, codeName])
  787. }
  788.  
  789. model WorkflowContainer {
  790. id String @id @default(cuid())
  791. createdAt DateTime @default(now())
  792. updatedAt DateTime @default(now())
  793. order Int @default(0)
  794. workflowSchemaId String
  795. name String
  796. codeName String?
  797. workflowCards WorkflowCard[]
  798. workflowSchema WorkflowSchema @relation(fields: [workflowSchemaId], references: [id], onDelete: Cascade)
  799. }
  800.  
  801. model WorkflowSchema {
  802. id String @id @default(cuid())
  803. createdAt DateTime @default(now())
  804. updatedAt DateTime @default(now())
  805. description String?
  806. url String?
  807. internal Boolean @default(false)
  808. name String
  809. productId String
  810. slug String?
  811. type WorkflowType
  812. createdById String
  813. published Boolean @default(false)
  814. workflowCards WorkflowCard[]
  815. workflowContainers WorkflowContainer[]
  816. workflowFields WorkflowFields[]
  817. user User @relation(fields: [createdById], references: [id])
  818. product Product @relation(fields: [productId], references: [id])
  819. workflowSubmissions WorkflowSubmission[]
  820. }
  821.  
  822. model WorkflowSubmission {
  823. id String @id @default(cuid())
  824. createdAt DateTime @default(now())
  825. updatedAt DateTime @default(now()) @updatedAt
  826. workflowSchemaId String
  827. conversationId String
  828. payload Json
  829. conversation Conversation @relation(fields: [conversationId], references: [id])
  830. workflowSchema WorkflowSchema @relation(fields: [workflowSchemaId], references: [id])
  831. }
  832.  
  833. model Entity {
  834. id String @id @default(cuid())
  835. createdAt DateTime @default(now())
  836. updatedAt DateTime @default(now())
  837. name String
  838. description String?
  839. entityFields EntityField[]
  840. products Product[] @relation("EntityToProduct")
  841. }
  842.  
  843. model EntityField {
  844. id String @id @default(cuid())
  845. name String
  846. type FieldTypes
  847. recordHistory Boolean @default(false)
  848. description String?
  849. required Boolean @default(false)
  850. defaultValue String?
  851. createdAt DateTime @default(now())
  852. updatedAt DateTime @default(now())
  853. entityId String
  854. initActionId String?
  855. entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)
  856. initAction Action? @relation(fields: [initActionId], references: [id])
  857. values EntityFieldValue[]
  858. WorkflowFields WorkflowFields[]
  859. }
  860.  
  861. model EntityFieldValue {
  862. id String @id @default(cuid())
  863. createdAt DateTime @default(now())
  864. updatedAt DateTime @default(now())
  865. value String?
  866. entityFieldId String
  867. conversationId String?
  868. organizationId String?
  869. hierarchy Hierarchy @default(local)
  870. entityField EntityField @relation(fields: [entityFieldId], references: [id])
  871. history FieldHistory[]
  872.  
  873. @@unique([entityFieldId, conversationId])
  874. }
  875.  
  876. model FieldHistory {
  877. id String @id @default(cuid())
  878. createdAt DateTime @default(now())
  879. oldValue String
  880. newValue String
  881. entityFieldValueId String
  882. cause String?
  883. entityFieldValue EntityFieldValue @relation(fields: [entityFieldValueId], references: [id])
  884. }
  885.  
  886. model Action {
  887. id String @id @default(cuid())
  888. createdAt DateTime @default(now())
  889. updatedAt DateTime @default(now())
  890. description String?
  891. ctxExecution String?
  892. fields EntityField[]
  893. }
  894.  
  895. model Recipient {
  896. id Int @id @default(autoincrement())
  897. documentId Int?
  898. templateId Int?
  899. email String @db.VarChar(255)
  900. name String @default("") @db.VarChar(255)
  901. token String
  902. expired DateTime?
  903. signedAt DateTime?
  904. readStatus ReadStatus @default(NOT_OPENED)
  905. signingStatus SigningStatus @default(NOT_SIGNED)
  906. sendStatus SendStatus @default(NOT_SENT)
  907. createdAt DateTime @default(now())
  908. updatedAt DateTime @default(now())
  909. Field Field[]
  910. Document Document? @relation(fields: [documentId], references: [id], onDelete: Cascade)
  911. Signature Signature[]
  912.  
  913. @@unique([documentId, email])
  914. @@unique([templateId, email])
  915. @@index([documentId])
  916. @@index([templateId])
  917. @@index([token])
  918. }
  919.  
  920. model Signature {
  921. id Int @id @default(autoincrement())
  922. created DateTime @default(now())
  923. recipientId Int
  924. fieldId Int @unique
  925. signatureImageAsBase64 String?
  926. typedSignature String?
  927. Field Field @relation(fields: [fieldId], references: [id])
  928. Recipient Recipient @relation(fields: [recipientId], references: [id], onDelete: Cascade)
  929.  
  930. @@index([recipientId])
  931. }
  932.  
  933. enum FormFieldType {
  934. TEXT
  935. TEXTAREA
  936. SELECT
  937. BIG_SELECT
  938. HEADING
  939. PARAGRAPH
  940. SPACER
  941. CHECKBOX
  942. NUMBER
  943. PERCENTAGE
  944. ZIPCODE
  945. PHONE_NUMBER
  946. SSN
  947. DATE
  948. CURRENCY
  949. TIN
  950. LOCATION
  951. }
  952.  
  953. enum FieldTypes {
  954. string
  955. number
  956. boolean
  957. date
  958. time
  959. dateTime
  960. email
  961. phone
  962. url
  963. image
  964. color
  965. password
  966. currency
  967. geolocation
  968. address
  969. }
  970.  
  971. enum FunctionType {
  972. query
  973. mutation
  974. }
  975.  
  976. enum FunctionActionStatus {
  977. executed
  978. approved
  979. rejected
  980. pending
  981. executing
  982. }
  983.  
  984. enum HILDecision {
  985. APPROVED
  986. REJECTED
  987. PENDING
  988. EXECUTED
  989. }
  990.  
  991. enum MemoryType {
  992. observation
  993. reflection
  994. }
  995.  
  996. enum Hierarchy {
  997. local
  998. global
  999. }
  1000.  
  1001. enum WorkflowType {
  1002. applicationForm
  1003. }
  1004.  
  1005. enum MessageType {
  1006. client
  1007. agent
  1008. }
  1009.  
  1010. enum ClientFileStatus {
  1011. pending
  1012. processing
  1013. approved
  1014. rejected
  1015. private
  1016. }
  1017.  
  1018. enum Visibility {
  1019. private
  1020. public
  1021. }
  1022.  
  1023. enum CommunicationMedium {
  1024. EMAIL
  1025. PHONE
  1026. SMS
  1027. WHATSAPP
  1028. }
  1029.  
  1030. enum displayStatus {
  1031. confirmed
  1032. mismatch
  1033. unknown
  1034. }
  1035.  
  1036. enum UserRole {
  1037. organizationAdmin
  1038. humanOperator
  1039. admin
  1040. applicant
  1041. lead
  1042. You
  1043. reminder
  1044. }
  1045.  
  1046. enum AgentType {
  1047. LOAN
  1048. CREDIT_CARD
  1049. }
  1050.  
  1051. enum ActionStatus {
  1052. REVIEW_REQUIRED
  1053. PROCESSING
  1054. APPROVED
  1055. ORGANIZATION_REVIEW_REQUIRED
  1056. REMINDER_REVIEW_REQUIRE
  1057. }
  1058.  
  1059. enum OrganizationCheckFormType {
  1060. TEXTAREA
  1061. TEXT
  1062. SELECT
  1063. }
  1064.  
  1065. enum DocumentType {
  1066. BANK_STATEMENT
  1067. PERSONAL_TAX_RETURN
  1068. BUSINESS_TAX_RETURN
  1069. W2_TAX_FORM
  1070. INCOME_STATEMENT
  1071. OTHER
  1072. }
  1073.  
  1074. enum ConversationCheckStatus {
  1075. APPROVED
  1076. REJECTED
  1077. PENDING
  1078. }
  1079.  
  1080. enum Company {
  1081. Microsoft
  1082. Google
  1083. }
  1084.  
  1085. enum TaskType {
  1086. action
  1087. reminder
  1088. }
  1089.  
  1090. enum ReminderType {
  1091. automatic
  1092. heartbeat
  1093. }
  1094.  
  1095. enum DocumentStatus {
  1096. DRAFT
  1097. PENDING
  1098. COMPLETED
  1099. }
  1100.  
  1101. enum FieldType {
  1102. SIGNATURE
  1103. FREE_SIGNATURE
  1104. NAME
  1105. EMAIL
  1106. DATE
  1107. TEXT
  1108. }
  1109.  
  1110. enum ReadStatus {
  1111. NOT_OPENED
  1112. OPENED
  1113. }
  1114.  
  1115. enum SendStatus {
  1116. NOT_SENT
  1117. SENT
  1118. }
  1119.  
  1120. enum SigningStatus {
  1121. NOT_SIGNED
  1122. SIGNED
  1123. }
  1124.  
Add Comment
Please, Sign In to add comment