schema.prisma 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. @@index([userUid])
  26. }
  27. model TeamInvitation {
  28. id String @id @default(cuid())
  29. teamID String
  30. team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
  31. creatorUid String
  32. inviteeEmail String
  33. inviteeRole TeamMemberRole
  34. @@unique([teamID, inviteeEmail])
  35. @@index([teamID])
  36. }
  37. model TeamCollection {
  38. id String @id @default(cuid())
  39. parentID String?
  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
  64. request Json
  65. creatorUid String?
  66. createdOn DateTime @default(now())
  67. @@unique(fields: [id, creatorUid], name: "creator_uid_shortcode_unique")
  68. }
  69. model TeamEnvironment {
  70. id String @id @default(cuid())
  71. teamID String
  72. team Team @relation(fields: [teamID], references: [id], onDelete: Cascade)
  73. name String
  74. variables Json
  75. }
  76. model User {
  77. uid String @id @default(cuid())
  78. displayName String?
  79. email String? @unique
  80. photoURL String?
  81. isAdmin Boolean @default(false)
  82. refreshToken String?
  83. providerAccounts Account[]
  84. VerificationToken VerificationToken[]
  85. settings UserSettings?
  86. UserHistory UserHistory[]
  87. UserEnvironments UserEnvironment[]
  88. userCollections UserCollection[]
  89. userRequests UserRequest[]
  90. currentRESTSession Json?
  91. currentGQLSession Json?
  92. createdOn DateTime @default(now()) @db.Timestamp(3)
  93. invitedUsers InvitedUsers[]
  94. }
  95. model Account {
  96. id String @id @default(cuid())
  97. userId String
  98. user User @relation(fields: [userId], references: [uid], onDelete: Cascade)
  99. provider String
  100. providerAccountId String
  101. providerRefreshToken String?
  102. providerAccessToken String?
  103. providerScope String?
  104. loggedIn DateTime @default(now()) @db.Timestamp(3)
  105. @@unique(fields: [provider, providerAccountId], name: "verifyProviderAccount")
  106. }
  107. model VerificationToken {
  108. deviceIdentifier String
  109. token String @unique @default(cuid())
  110. userUid String
  111. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  112. expiresOn DateTime @db.Timestamp(3)
  113. @@unique(fields: [deviceIdentifier, token], name: "passwordless_deviceIdentifier_tokens")
  114. }
  115. model UserSettings {
  116. id String @id @default(cuid())
  117. userUid String @unique
  118. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  119. properties Json
  120. updatedOn DateTime @updatedAt @db.Timestamp(3)
  121. }
  122. model UserHistory {
  123. id String @id @default(cuid())
  124. userUid String
  125. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  126. reqType ReqType
  127. request Json
  128. responseMetadata Json
  129. isStarred Boolean
  130. executedOn DateTime @default(now()) @db.Timestamp(3)
  131. }
  132. enum ReqType {
  133. REST
  134. GQL
  135. }
  136. model UserEnvironment {
  137. id String @id @default(cuid())
  138. userUid String
  139. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  140. name String?
  141. variables Json
  142. isGlobal Boolean
  143. }
  144. model InvitedUsers {
  145. adminUid String
  146. user User @relation(fields: [adminUid], references: [uid], onDelete: Cascade)
  147. adminEmail String
  148. inviteeEmail String @unique
  149. invitedOn DateTime @default(now()) @db.Timestamp(3)
  150. }
  151. model UserRequest {
  152. id String @id @default(cuid())
  153. userCollection UserCollection @relation(fields: [collectionID], references: [id])
  154. collectionID String
  155. userUid String
  156. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  157. title String
  158. request Json
  159. type ReqType
  160. orderIndex Int
  161. createdOn DateTime @default(now()) @db.Timestamp(3)
  162. updatedOn DateTime @updatedAt @db.Timestamp(3)
  163. }
  164. model UserCollection {
  165. id String @id @default(cuid())
  166. parentID String?
  167. parent UserCollection? @relation("ParentUserCollection", fields: [parentID], references: [id], onDelete: Cascade)
  168. children UserCollection[] @relation("ParentUserCollection")
  169. requests UserRequest[]
  170. userUid String
  171. user User @relation(fields: [userUid], references: [uid], onDelete: Cascade)
  172. title String
  173. orderIndex Int
  174. type ReqType
  175. createdOn DateTime @default(now()) @db.Timestamp(3)
  176. updatedOn DateTime @updatedAt @db.Timestamp(3)
  177. }
  178. enum TeamMemberRole {
  179. OWNER
  180. VIEWER
  181. EDITOR
  182. }