schema.prisma 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. createdOn DateTime @default(now()) @db.Timestamp(3)
  96. invitedUsers InvitedUsers[]
  97. shortcodes Shortcode[]
  98. }
  99. model Account {
  100. id String @id @default(cuid())
  101. userId String
  102. user User @relation(fields: [userId], references: [uid], onDelete: Cascade)
  103. provider String
  104. providerAccountId String
  105. providerRefreshToken String?
  106. providerAccessToken String?
  107. providerScope String?
  108. loggedIn DateTime @default(now()) @db.Timestamp(3)
  109. @@unique(fields: [provider, providerAccountId], name: "verifyProviderAccount")
  110. }
  111. model VerificationToken {
  112. deviceIdentifier String
  113. token String @unique @default(cuid())
  114. userUid String
  115. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  116. expiresOn DateTime @db.Timestamp(3)
  117. @@unique(fields: [deviceIdentifier, token], name: "passwordless_deviceIdentifier_tokens")
  118. }
  119. model UserSettings {
  120. id String @id @default(cuid())
  121. userUid String @unique
  122. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  123. properties Json
  124. updatedOn DateTime @updatedAt @db.Timestamp(3)
  125. }
  126. model UserHistory {
  127. id String @id @default(cuid())
  128. userUid String
  129. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  130. reqType ReqType
  131. request Json
  132. responseMetadata Json
  133. isStarred Boolean
  134. executedOn DateTime @default(now()) @db.Timestamp(3)
  135. }
  136. enum ReqType {
  137. REST
  138. GQL
  139. }
  140. model UserEnvironment {
  141. id String @id @default(cuid())
  142. userUid String
  143. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  144. name String?
  145. variables Json
  146. isGlobal Boolean
  147. }
  148. model InvitedUsers {
  149. adminUid String
  150. user User @relation(fields: [adminUid], references: [uid], onDelete: Cascade)
  151. adminEmail String
  152. inviteeEmail String @unique
  153. invitedOn DateTime @default(now()) @db.Timestamp(3)
  154. }
  155. model UserRequest {
  156. id String @id @default(cuid())
  157. userCollection UserCollection @relation(fields: [collectionID], references: [id])
  158. collectionID String
  159. userUid String
  160. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  161. title String
  162. request Json
  163. type ReqType
  164. orderIndex Int
  165. createdOn DateTime @default(now()) @db.Timestamp(3)
  166. updatedOn DateTime @updatedAt @db.Timestamp(3)
  167. }
  168. model UserCollection {
  169. id String @id @default(cuid())
  170. parentID String?
  171. parent UserCollection? @relation("ParentUserCollection", fields: [parentID], references: [id], onDelete: Cascade)
  172. children UserCollection[] @relation("ParentUserCollection")
  173. requests UserRequest[]
  174. userUid String
  175. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  176. title String
  177. data Json?
  178. orderIndex Int
  179. type ReqType
  180. createdOn DateTime @default(now()) @db.Timestamp(3)
  181. updatedOn DateTime @updatedAt @db.Timestamp(3)
  182. }
  183. enum TeamMemberRole {
  184. OWNER
  185. VIEWER
  186. EDITOR
  187. }
  188. model InfraConfig {
  189. id String @id @default(cuid())
  190. name String @unique
  191. value String?
  192. active Boolean @default(true) // Use case: Let's say, Admin wants to disable Google SSO, but doesn't want to delete the config
  193. createdOn DateTime @default(now()) @db.Timestamp(3)
  194. updatedOn DateTime @updatedAt @db.Timestamp(3)
  195. }