schema.prisma 6.2 KB

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