schema.prisma 7.3 KB

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