schema.prisma 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. datasource db {
  2. provider = "postgresql"
  3. url = env("DATABASE_URL")
  4. }
  5. generator client {
  6. provider = "prisma-client-js"
  7. binaryTargets = ["native", "debian-openssl-1.1.x", "debian-openssl-3.0.x"]
  8. }
  9. model Team {
  10. id String @id @default(cuid())
  11. name String
  12. members TeamMember[]
  13. TeamInvitation TeamInvitation[]
  14. TeamCollection TeamCollection[]
  15. TeamRequest TeamRequest[]
  16. TeamEnvironment TeamEnvironment[]
  17. }
  18. model TeamMember {
  19. id String @id @default(uuid()) // Membership ID
  20. role TeamMemberRole
  21. userUid String
  22. teamID String
  23. team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
  24. @@unique([teamID, userUid])
  25. }
  26. model TeamInvitation {
  27. id String @id @default(cuid())
  28. teamID String
  29. team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
  30. creatorUid String
  31. inviteeEmail String
  32. inviteeRole TeamMemberRole
  33. @@unique([teamID, inviteeEmail])
  34. @@index([teamID])
  35. }
  36. model TeamCollection {
  37. id String @id @default(cuid())
  38. parentID String?
  39. parent TeamCollection? @relation("TeamCollectionChildParent", fields: [parentID], references: [id])
  40. children TeamCollection[] @relation("TeamCollectionChildParent")
  41. requests TeamRequest[]
  42. teamID String
  43. team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
  44. title String
  45. orderIndex Int
  46. createdOn DateTime @default(now()) @db.Timestamp(3)
  47. updatedOn DateTime @updatedAt @db.Timestamp(3)
  48. }
  49. model TeamRequest {
  50. id String @id @default(cuid())
  51. collectionID String
  52. collection TeamCollection @relation(fields: [collectionID], references: [id], onDelete: Cascade)
  53. teamID String
  54. team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
  55. title String
  56. request Json
  57. orderIndex Int
  58. createdOn DateTime @default(now()) @db.Timestamp(3)
  59. updatedOn DateTime @updatedAt @db.Timestamp(3)
  60. }
  61. model Shortcode {
  62. id String @id @unique
  63. request Json
  64. embedProperties Json?
  65. creatorUid String?
  66. User User? @relation(fields: [creatorUid], references: [uid])
  67. createdOn DateTime @default(now())
  68. updatedOn DateTime @updatedAt @default(now())
  69. @@unique(fields: [id, creatorUid], name: "creator_uid_shortcode_unique")
  70. }
  71. model TeamEnvironment {
  72. id String @id @default(cuid())
  73. teamID String
  74. team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
  75. name String
  76. variables Json
  77. }
  78. model User {
  79. uid String @id @default(cuid())
  80. displayName String?
  81. email String? @unique
  82. photoURL String?
  83. isAdmin Boolean @default(false)
  84. refreshToken String?
  85. providerAccounts Account[]
  86. VerificationToken VerificationToken[]
  87. settings UserSettings?
  88. UserHistory UserHistory[]
  89. UserEnvironments UserEnvironment[]
  90. userCollections UserCollection[]
  91. userRequests UserRequest[]
  92. currentRESTSession Json?
  93. currentGQLSession Json?
  94. createdOn DateTime @default(now()) @db.Timestamp(3)
  95. invitedUsers InvitedUsers[]
  96. shortcodes Shortcode[]
  97. }
  98. model Account {
  99. id String @id @default(cuid())
  100. userId String
  101. user User @relation(fields: [userId], references: [uid], onDelete: Cascade)
  102. provider String
  103. providerAccountId String
  104. providerRefreshToken String?
  105. providerAccessToken String?
  106. providerScope String?
  107. loggedIn DateTime @default(now()) @db.Timestamp(3)
  108. @@unique(fields: [provider, providerAccountId], name: "verifyProviderAccount")
  109. }
  110. model VerificationToken {
  111. deviceIdentifier String
  112. token String @unique @default(cuid())
  113. userUid String
  114. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  115. expiresOn DateTime @db.Timestamp(3)
  116. @@unique(fields: [deviceIdentifier, token], name: "passwordless_deviceIdentifier_tokens")
  117. }
  118. model UserSettings {
  119. id String @id @default(cuid())
  120. userUid String @unique
  121. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  122. properties Json
  123. updatedOn DateTime @updatedAt @db.Timestamp(3)
  124. }
  125. model UserHistory {
  126. id String @id @default(cuid())
  127. userUid String
  128. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  129. reqType ReqType
  130. request Json
  131. responseMetadata Json
  132. isStarred Boolean
  133. executedOn DateTime @default(now()) @db.Timestamp(3)
  134. }
  135. enum ReqType {
  136. REST
  137. GQL
  138. }
  139. model UserEnvironment {
  140. id String @id @default(cuid())
  141. userUid String
  142. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  143. name String?
  144. variables Json
  145. isGlobal Boolean
  146. }
  147. model InvitedUsers {
  148. adminUid String
  149. user User @relation(fields: [adminUid], references: [uid], onDelete: Cascade)
  150. adminEmail String
  151. inviteeEmail String @unique
  152. invitedOn DateTime @default(now()) @db.Timestamp(3)
  153. }
  154. model UserRequest {
  155. id String @id @default(cuid())
  156. userCollection UserCollection @relation(fields: [collectionID], references: [id])
  157. collectionID String
  158. userUid String
  159. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  160. title String
  161. request Json
  162. type ReqType
  163. orderIndex Int
  164. createdOn DateTime @default(now()) @db.Timestamp(3)
  165. updatedOn DateTime @updatedAt @db.Timestamp(3)
  166. }
  167. model UserCollection {
  168. id String @id @default(cuid())
  169. parentID String?
  170. parent UserCollection? @relation("ParentUserCollection", fields: [parentID], references: [id], onDelete: Cascade)
  171. children UserCollection[] @relation("ParentUserCollection")
  172. requests UserRequest[]
  173. userUid String
  174. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  175. title String
  176. orderIndex Int
  177. type ReqType
  178. createdOn DateTime @default(now()) @db.Timestamp(3)
  179. updatedOn DateTime @updatedAt @db.Timestamp(3)
  180. }
  181. enum TeamMemberRole {
  182. OWNER
  183. VIEWER
  184. EDITOR
  185. }