schema.prisma 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. // This is your Prisma schema file
  2. // learn more about it in the docs: https://pris.ly/d/prisma-schema
  3. generator client {
  4. provider = "prisma-client-js"
  5. }
  6. datasource db {
  7. provider = "postgresql"
  8. url = env("DATABASE_URL")
  9. }
  10. enum UserRole {
  11. admin
  12. user
  13. }
  14. model User {
  15. id String @id
  16. firstName String @default("")
  17. lastName String @default("")
  18. name String
  19. email String @unique
  20. emailVerified Boolean
  21. image String?
  22. locale String? @default("fr")
  23. createdAt DateTime
  24. updatedAt DateTime
  25. sessions Session[]
  26. accounts Account[]
  27. feedbacks Feedbacks[]
  28. role UserRole? @default(user)
  29. banned Boolean? @default(false)
  30. banReason String?
  31. banExpires DateTime?
  32. WorkoutSession WorkoutSession[]
  33. @@map("user")
  34. }
  35. model Session {
  36. id String @id
  37. expiresAt DateTime
  38. token String @unique
  39. createdAt DateTime
  40. updatedAt DateTime
  41. ipAddress String?
  42. userAgent String?
  43. userId String
  44. user User @relation(fields: [userId], references: [id], onDelete: Cascade)
  45. impersonatedBy String?
  46. @@map("session")
  47. }
  48. model Account {
  49. id String @id
  50. accountId String
  51. providerId String
  52. userId String
  53. user User @relation(fields: [userId], references: [id], onDelete: Cascade)
  54. accessToken String?
  55. refreshToken String?
  56. idToken String?
  57. accessTokenExpiresAt DateTime?
  58. refreshTokenExpiresAt DateTime?
  59. scope String?
  60. password String?
  61. createdAt DateTime
  62. updatedAt DateTime
  63. @@map("account")
  64. }
  65. model Verification {
  66. id String @id
  67. identifier String
  68. value String
  69. expiresAt DateTime
  70. createdAt DateTime?
  71. updatedAt DateTime?
  72. @@map("verification")
  73. }
  74. model Feedbacks {
  75. id String @id @default(cuid())
  76. review Int
  77. message String
  78. email String?
  79. userId String?
  80. user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
  81. createdAt DateTime @default(now())
  82. updatedAt DateTime @updatedAt
  83. @@map("feedbacks")
  84. }
  85. model Exercise {
  86. id String @id @default(cuid())
  87. name String
  88. nameEn String?
  89. description String? @db.Text
  90. descriptionEn String? @db.Text
  91. fullVideoUrl String? @db.Text
  92. fullVideoImageUrl String? @db.Text
  93. introduction String? @db.Text
  94. introductionEn String? @db.Text
  95. slug String? @unique
  96. slugEn String? @unique
  97. createdAt DateTime @default(now())
  98. updatedAt DateTime @updatedAt
  99. // Relations
  100. attributes ExerciseAttribute[]
  101. WorkoutSessionExercise WorkoutSessionExercise[]
  102. @@map("exercises")
  103. }
  104. model ExerciseAttributeName {
  105. id String @id @default(cuid())
  106. name ExerciseAttributeNameEnum @unique
  107. createdAt DateTime @default(now())
  108. updatedAt DateTime @updatedAt
  109. // Relations
  110. values ExerciseAttributeValue[]
  111. attributes ExerciseAttribute[]
  112. @@map("exercise_attribute_names")
  113. }
  114. model ExerciseAttributeValue {
  115. id String @id @default(cuid())
  116. attributeNameId String
  117. value ExerciseAttributeValueEnum
  118. createdAt DateTime @default(now())
  119. updatedAt DateTime @updatedAt
  120. // Relations
  121. attributeName ExerciseAttributeName @relation(fields: [attributeNameId], references: [id])
  122. attributes ExerciseAttribute[]
  123. @@unique([attributeNameId, value])
  124. @@map("exercise_attribute_values")
  125. }
  126. model ExerciseAttribute {
  127. id String @id @default(cuid())
  128. exerciseId String
  129. attributeNameId String
  130. attributeValueId String
  131. createdAt DateTime @default(now())
  132. updatedAt DateTime @updatedAt
  133. // Relations
  134. exercise Exercise @relation(fields: [exerciseId], references: [id], onDelete: Cascade)
  135. attributeName ExerciseAttributeName @relation(fields: [attributeNameId], references: [id])
  136. attributeValue ExerciseAttributeValue @relation(fields: [attributeValueId], references: [id])
  137. @@unique([exerciseId, attributeNameId, attributeValueId])
  138. @@map("exercise_attributes")
  139. }
  140. // Enums
  141. enum ExercisePrivacy {
  142. PUBLIC
  143. PRIVATE
  144. }
  145. // Noms d'attributs
  146. enum ExerciseAttributeNameEnum {
  147. TYPE
  148. PRIMARY_MUSCLE
  149. SECONDARY_MUSCLE
  150. EQUIPMENT
  151. MECHANICS_TYPE
  152. }
  153. // Toutes les valeurs possibles
  154. enum ExerciseAttributeValueEnum {
  155. // Types d'exercices
  156. BODYWEIGHT
  157. STRENGTH
  158. POWERLIFTING
  159. CALISTHENIC
  160. PLYOMETRICS
  161. STRETCHING
  162. STRONGMAN
  163. CARDIO
  164. STABILIZATION
  165. POWER
  166. RESISTANCE
  167. CROSSFIT
  168. WEIGHTLIFTING
  169. // Groupes musculaires
  170. BICEPS
  171. SHOULDERS
  172. CHEST
  173. BACK
  174. GLUTES
  175. TRICEPS
  176. HAMSTRINGS
  177. QUADRICEPS
  178. FOREARMS
  179. CALVES
  180. TRAPS
  181. ABDOMINALS
  182. NECK
  183. LATS
  184. ADDUCTORS
  185. ABDUCTORS
  186. OBLIQUES
  187. GROIN
  188. FULL_BODY
  189. ROTATOR_CUFF
  190. HIP_FLEXOR
  191. ACHILLES_TENDON
  192. FINGERS
  193. // Équipements
  194. DUMBBELL
  195. KETTLEBELLS
  196. BARBELL
  197. SMITH_MACHINE
  198. BODY_ONLY
  199. OTHER
  200. BANDS
  201. EZ_BAR
  202. MACHINE
  203. DESK
  204. PULLUP_BAR
  205. NONE
  206. CABLE
  207. MEDICINE_BALL
  208. SWISS_BALL
  209. FOAM_ROLL
  210. WEIGHT_PLATE
  211. TRX
  212. BOX
  213. ROPES
  214. SPIN_BIKE
  215. STEP
  216. BOSU
  217. TYRE
  218. SANDBAG
  219. POLE
  220. BENCH
  221. WALL
  222. BAR
  223. RACK
  224. CAR
  225. SLED
  226. CHAIN
  227. SKIERG
  228. ROPE
  229. NA
  230. // Types de mécanique
  231. ISOLATION
  232. COMPOUND
  233. }
  234. model WorkoutSession {
  235. id String @id @default(cuid())
  236. userId String
  237. user User @relation(fields: [userId], references: [id])
  238. startedAt DateTime
  239. endedAt DateTime?
  240. duration Int? // en secondes
  241. exercises WorkoutSessionExercise[]
  242. muscles ExerciseAttributeValueEnum[] @default([])
  243. @@map("workout_sessions")
  244. }
  245. model WorkoutSessionExercise {
  246. id String @id @default(cuid())
  247. workoutSessionId String
  248. exerciseId String
  249. order Int
  250. workoutSession WorkoutSession @relation(fields: [workoutSessionId], references: [id], onDelete: Cascade)
  251. exercise Exercise @relation(fields: [exerciseId], references: [id])
  252. sets WorkoutSet[]
  253. @@map("workout_session_exercises")
  254. }
  255. model WorkoutSet {
  256. id String @id @default(cuid())
  257. workoutSessionExerciseId String
  258. setIndex Int
  259. type WorkoutSetType
  260. types WorkoutSetType[] @default([])
  261. valuesInt Int[] @default([])
  262. valuesSec Int[] @default([])
  263. units WorkoutSetUnit[] @default([])
  264. completed Boolean @default(false)
  265. workoutSessionExercise WorkoutSessionExercise @relation(fields: [workoutSessionExerciseId], references: [id], onDelete: Cascade)
  266. @@map("workout_sets")
  267. }
  268. enum WorkoutSetType {
  269. TIME
  270. WEIGHT
  271. REPS
  272. BODYWEIGHT
  273. NA
  274. }
  275. enum WorkoutSetUnit {
  276. kg
  277. lbs
  278. }