schema.prisma 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. data Json?
  40. parent TeamCollection? @relation("TeamCollectionChildParent", fields: [parentID], references: [id])
  41. children TeamCollection[] @relation("TeamCollectionChildParent")
  42. requests TeamRequest[]
  43. teamID String
  44. team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
  45. title String
  46. orderIndex Int
  47. createdOn DateTime @default(now()) @db.Timestamp(3)
  48. updatedOn DateTime @updatedAt @db.Timestamp(3)
  49. }
  50. model TeamRequest {
  51. id String @id @default(cuid())
  52. collectionID String
  53. collection TeamCollection @relation(fields: [collectionID], references: [id], onDelete: Cascade)
  54. teamID String
  55. team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
  56. title String
  57. request Json
  58. orderIndex Int
  59. createdOn DateTime @default(now()) @db.Timestamp(3)
  60. updatedOn DateTime @updatedAt @db.Timestamp(3)
  61. }
  62. model Shortcode {
  63. id String @id @unique
  64. request Json
  65. embedProperties Json?
  66. creatorUid String?
  67. User User? @relation(fields: [creatorUid], references: [uid])
  68. createdOn DateTime @default(now())
  69. updatedOn DateTime @default(now()) @updatedAt
  70. @@unique(fields: [id, creatorUid], name: "creator_uid_shortcode_unique")
  71. }
  72. model TeamEnvironment {
  73. id String @id @default(cuid())
  74. teamID String
  75. team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
  76. name String
  77. variables Json
  78. }
  79. model User {
  80. uid String @id @default(cuid())
  81. displayName String?
  82. email String? @unique
  83. photoURL String?
  84. isAdmin Boolean @default(false)
  85. refreshToken String?
  86. providerAccounts Account[]
  87. VerificationToken VerificationToken[]
  88. settings UserSettings?
  89. UserHistory UserHistory[]
  90. UserEnvironments UserEnvironment[]
  91. userCollections UserCollection[]
  92. userRequests UserRequest[]
  93. currentRESTSession Json?
  94. currentGQLSession Json?
  95. lastLoggedOn DateTime? @db.Timestamp(3)
  96. lastActiveOn DateTime? @db.Timestamp(3)
  97. createdOn DateTime @default(now()) @db.Timestamp(3)
  98. invitedUsers InvitedUsers[]
  99. shortcodes Shortcode[]
  100. personalAccessTokens PersonalAccessToken[]
  101. }
  102. model Account {
  103. id String @id @default(cuid())
  104. userId String
  105. user User @relation(fields: [userId], references: [uid], onDelete: Cascade)
  106. provider String
  107. providerAccountId String
  108. providerRefreshToken String?
  109. providerAccessToken String?
  110. providerScope String?
  111. loggedIn DateTime @default(now()) @db.Timestamp(3)
  112. @@unique(fields: [provider, providerAccountId], name: "verifyProviderAccount")
  113. }
  114. model VerificationToken {
  115. deviceIdentifier String
  116. token String @unique @default(cuid())
  117. userUid String
  118. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  119. expiresOn DateTime @db.Timestamp(3)
  120. @@unique(fields: [deviceIdentifier, token], name: "passwordless_deviceIdentifier_tokens")
  121. }
  122. model UserSettings {
  123. id String @id @default(cuid())
  124. userUid String @unique
  125. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  126. properties Json
  127. updatedOn DateTime @updatedAt @db.Timestamp(3)
  128. }
  129. model UserHistory {
  130. id String @id @default(cuid())
  131. userUid String
  132. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  133. reqType ReqType
  134. request Json
  135. responseMetadata Json
  136. isStarred Boolean
  137. executedOn DateTime @default(now()) @db.Timestamp(3)
  138. }
  139. enum ReqType {
  140. REST
  141. GQL
  142. }
  143. model UserEnvironment {
  144. id String @id @default(cuid())
  145. userUid String
  146. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  147. name String?
  148. variables Json
  149. isGlobal Boolean
  150. }
  151. model InvitedUsers {
  152. adminUid String
  153. user User @relation(fields: [adminUid], references: [uid], onDelete: Cascade)
  154. adminEmail String
  155. inviteeEmail String @unique
  156. invitedOn DateTime @default(now()) @db.Timestamp(3)
  157. }
  158. model UserRequest {
  159. id String @id @default(cuid())
  160. userCollection UserCollection @relation(fields: [collectionID], references: [id])
  161. collectionID String
  162. userUid String
  163. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  164. title String
  165. request Json
  166. type ReqType
  167. orderIndex Int
  168. createdOn DateTime @default(now()) @db.Timestamp(3)
  169. updatedOn DateTime @updatedAt @db.Timestamp(3)
  170. }
  171. model UserCollection {
  172. id String @id @default(cuid())
  173. parentID String?
  174. parent UserCollection? @relation("ParentUserCollection", fields: [parentID], references: [id], onDelete: Cascade)
  175. children UserCollection[] @relation("ParentUserCollection")
  176. requests UserRequest[]
  177. userUid String
  178. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  179. title String
  180. data Json?
  181. orderIndex Int
  182. type ReqType
  183. createdOn DateTime @default(now()) @db.Timestamp(3)
  184. updatedOn DateTime @updatedAt @db.Timestamp(3)
  185. }
  186. enum TeamMemberRole {
  187. OWNER
  188. VIEWER
  189. EDITOR
  190. }
  191. model InfraConfig {
  192. id String @id @default(cuid())
  193. name String @unique
  194. value String?
  195. isEncrypted Boolean @default(false) // Use case: Let's say, Admin wants to store a Secret Key, but doesn't want to store it in plain text in `value` column
  196. active Boolean @default(true) // Use case: Let's say, Admin wants to disable Google SSO, but doesn't want to delete the config
  197. createdOn DateTime @default(now()) @db.Timestamp(3)
  198. updatedOn DateTime @updatedAt @db.Timestamp(3)
  199. }
  200. model PersonalAccessToken {
  201. id String @id @default(cuid())
  202. userUid String
  203. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  204. label String
  205. token String @unique @default(uuid())
  206. expiresOn DateTime? @db.Timestamp(3)
  207. createdOn DateTime @default(now()) @db.Timestamp(3)
  208. updatedOn DateTime @updatedAt @db.Timestamp(3)
  209. }
  210. model InfraToken {
  211. id String @id @default(cuid())
  212. creatorUid String
  213. label String
  214. token String @unique @default(uuid())
  215. expiresOn DateTime? @db.Timestamp(3)
  216. createdOn DateTime @default(now()) @db.Timestamp(3)
  217. updatedOn DateTime @default(now()) @db.Timestamp(3)
  218. }