@coursebuilder/adapter-drizzle 0.5.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/dist/{chunk-QQA7STVO.js → chunk-3WYG5OE7.js} +2 -2
  2. package/dist/{chunk-6SLQW6OM.js → chunk-5XTOCFDB.js} +5 -2
  3. package/dist/{chunk-2UU2F4DM.js → chunk-6MRFUIH5.js} +6 -2
  4. package/dist/{chunk-XIGJFVUM.js → chunk-6YPHJWS2.js} +9 -2
  5. package/dist/{chunk-EFVZ7IN4.js → chunk-A6XPL665.js} +2 -2
  6. package/dist/{chunk-3NUCFLQJ.js → chunk-BLDW3QUS.js} +7 -3
  7. package/dist/{chunk-QP6YMUQX.js → chunk-DKJO4Y3K.js} +7 -3
  8. package/dist/{chunk-P4VXXTVA.js → chunk-EHRARBRS.js} +4 -1
  9. package/dist/{chunk-YVVXDJHI.js → chunk-ET3QAIY7.js} +9 -2
  10. package/dist/{chunk-YMFPIZMO.js → chunk-GAKWXOAY.js} +2 -2
  11. package/dist/{chunk-4ZWS76VQ.js → chunk-KPBVZ44W.js} +7 -3
  12. package/dist/{chunk-ZYQYJNLK.js → chunk-L5ZAWSTN.js} +51 -29
  13. package/dist/{chunk-6ON2O6UD.js → chunk-MGZMGDQ5.js} +7 -3
  14. package/dist/{chunk-KDEWFXEP.js → chunk-MP4CUWYC.js} +6 -2
  15. package/dist/{chunk-JW2PFVLO.js → chunk-QGZ2F5SW.js} +1387 -868
  16. package/dist/{chunk-XJXCDN7B.js → chunk-RCL6HPBL.js} +8 -4
  17. package/dist/chunk-RP66NZN3.js +81 -0
  18. package/dist/{chunk-27UC2HEP.js → chunk-WFC55BSF.js} +7 -3
  19. package/dist/{chunk-GINRTL6J.js → chunk-WJWJ6E5Y.js} +6 -2
  20. package/dist/{chunk-YGRYHMCG.js → chunk-WPJZAYX7.js} +7 -3
  21. package/dist/index.js +20 -20
  22. package/dist/lib/mysql/index.cjs +1355 -787
  23. package/dist/lib/mysql/index.cjs.map +1 -1
  24. package/dist/lib/mysql/index.d.cts +4201 -1667
  25. package/dist/lib/mysql/index.d.ts +4201 -1667
  26. package/dist/lib/mysql/index.js +20 -20
  27. package/dist/lib/mysql/schemas/auth/accounts.cjs +109 -93
  28. package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
  29. package/dist/lib/mysql/schemas/auth/accounts.js +10 -11
  30. package/dist/lib/mysql/schemas/auth/device-access-token.cjs +104 -85
  31. package/dist/lib/mysql/schemas/auth/device-access-token.cjs.map +1 -1
  32. package/dist/lib/mysql/schemas/auth/device-access-token.d.cts +16 -0
  33. package/dist/lib/mysql/schemas/auth/device-access-token.d.ts +16 -0
  34. package/dist/lib/mysql/schemas/auth/device-access-token.js +11 -12
  35. package/dist/lib/mysql/schemas/auth/device-verification.cjs +103 -87
  36. package/dist/lib/mysql/schemas/auth/device-verification.cjs.map +1 -1
  37. package/dist/lib/mysql/schemas/auth/device-verification.js +11 -12
  38. package/dist/lib/mysql/schemas/auth/role-permissions.cjs +102 -82
  39. package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
  40. package/dist/lib/mysql/schemas/auth/role-permissions.js +11 -12
  41. package/dist/lib/mysql/schemas/auth/roles.cjs +106 -82
  42. package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
  43. package/dist/lib/mysql/schemas/auth/roles.d.cts +16 -0
  44. package/dist/lib/mysql/schemas/auth/roles.d.ts +16 -0
  45. package/dist/lib/mysql/schemas/auth/roles.js +10 -11
  46. package/dist/lib/mysql/schemas/auth/sessions.cjs +99 -83
  47. package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
  48. package/dist/lib/mysql/schemas/auth/sessions.js +11 -12
  49. package/dist/lib/mysql/schemas/auth/user-permissions.cjs +104 -84
  50. package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
  51. package/dist/lib/mysql/schemas/auth/user-permissions.d.cts +16 -0
  52. package/dist/lib/mysql/schemas/auth/user-permissions.d.ts +16 -0
  53. package/dist/lib/mysql/schemas/auth/user-permissions.js +10 -11
  54. package/dist/lib/mysql/schemas/auth/user-prefs.cjs +108 -88
  55. package/dist/lib/mysql/schemas/auth/user-prefs.cjs.map +1 -1
  56. package/dist/lib/mysql/schemas/auth/user-prefs.d.cts +16 -0
  57. package/dist/lib/mysql/schemas/auth/user-prefs.d.ts +16 -0
  58. package/dist/lib/mysql/schemas/auth/user-prefs.js +10 -11
  59. package/dist/lib/mysql/schemas/auth/user-roles.cjs +109 -85
  60. package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
  61. package/dist/lib/mysql/schemas/auth/user-roles.d.cts +16 -0
  62. package/dist/lib/mysql/schemas/auth/user-roles.d.ts +16 -0
  63. package/dist/lib/mysql/schemas/auth/user-roles.js +10 -11
  64. package/dist/lib/mysql/schemas/auth/users.cjs +288 -192
  65. package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
  66. package/dist/lib/mysql/schemas/auth/users.d.cts +1 -0
  67. package/dist/lib/mysql/schemas/auth/users.d.ts +1 -0
  68. package/dist/lib/mysql/schemas/auth/users.js +10 -11
  69. package/dist/lib/mysql/schemas/commerce/coupon.cjs +134 -98
  70. package/dist/lib/mysql/schemas/commerce/coupon.cjs.map +1 -1
  71. package/dist/lib/mysql/schemas/commerce/coupon.d.cts +16 -0
  72. package/dist/lib/mysql/schemas/commerce/coupon.d.ts +16 -0
  73. package/dist/lib/mysql/schemas/commerce/coupon.js +10 -11
  74. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs +5 -1
  75. package/dist/lib/mysql/schemas/commerce/merchant-account.cjs.map +1 -1
  76. package/dist/lib/mysql/schemas/commerce/merchant-account.d.cts +16 -0
  77. package/dist/lib/mysql/schemas/commerce/merchant-account.d.ts +16 -0
  78. package/dist/lib/mysql/schemas/commerce/merchant-account.js +1 -1
  79. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs +210 -17
  80. package/dist/lib/mysql/schemas/commerce/merchant-charge.cjs.map +1 -1
  81. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.cts +33 -0
  82. package/dist/lib/mysql/schemas/commerce/merchant-charge.d.ts +33 -0
  83. package/dist/lib/mysql/schemas/commerce/merchant-charge.js +11 -4
  84. package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs +5 -1
  85. package/dist/lib/mysql/schemas/commerce/merchant-coupon.cjs.map +1 -1
  86. package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.cts +16 -0
  87. package/dist/lib/mysql/schemas/commerce/merchant-coupon.d.ts +16 -0
  88. package/dist/lib/mysql/schemas/commerce/merchant-coupon.js +1 -1
  89. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs +5 -1
  90. package/dist/lib/mysql/schemas/commerce/merchant-customer.cjs.map +1 -1
  91. package/dist/lib/mysql/schemas/commerce/merchant-customer.d.cts +16 -0
  92. package/dist/lib/mysql/schemas/commerce/merchant-customer.d.ts +16 -0
  93. package/dist/lib/mysql/schemas/commerce/merchant-customer.js +1 -1
  94. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs +5 -1
  95. package/dist/lib/mysql/schemas/commerce/merchant-price.cjs.map +1 -1
  96. package/dist/lib/mysql/schemas/commerce/merchant-price.d.cts +16 -0
  97. package/dist/lib/mysql/schemas/commerce/merchant-price.d.ts +16 -0
  98. package/dist/lib/mysql/schemas/commerce/merchant-price.js +1 -1
  99. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs +5 -1
  100. package/dist/lib/mysql/schemas/commerce/merchant-product.cjs.map +1 -1
  101. package/dist/lib/mysql/schemas/commerce/merchant-product.d.cts +16 -0
  102. package/dist/lib/mysql/schemas/commerce/merchant-product.d.ts +16 -0
  103. package/dist/lib/mysql/schemas/commerce/merchant-product.js +1 -1
  104. package/dist/lib/mysql/schemas/commerce/merchant-session.cjs +5 -1
  105. package/dist/lib/mysql/schemas/commerce/merchant-session.cjs.map +1 -1
  106. package/dist/lib/mysql/schemas/commerce/merchant-session.d.cts +16 -0
  107. package/dist/lib/mysql/schemas/commerce/merchant-session.d.ts +16 -0
  108. package/dist/lib/mysql/schemas/commerce/merchant-session.js +1 -1
  109. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs +315 -0
  110. package/dist/lib/mysql/schemas/commerce/merchant-subscription.cjs.map +1 -0
  111. package/dist/lib/mysql/schemas/commerce/merchant-subscription.d.cts +161 -0
  112. package/dist/lib/mysql/schemas/commerce/merchant-subscription.d.ts +161 -0
  113. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js +20 -0
  114. package/dist/lib/mysql/schemas/commerce/merchant-subscription.js.map +1 -0
  115. package/dist/lib/mysql/schemas/commerce/price.cjs +108 -80
  116. package/dist/lib/mysql/schemas/commerce/price.cjs.map +1 -1
  117. package/dist/lib/mysql/schemas/commerce/price.d.cts +16 -0
  118. package/dist/lib/mysql/schemas/commerce/price.d.ts +16 -0
  119. package/dist/lib/mysql/schemas/commerce/price.js +10 -11
  120. package/dist/lib/mysql/schemas/commerce/product.cjs +134 -102
  121. package/dist/lib/mysql/schemas/commerce/product.cjs.map +1 -1
  122. package/dist/lib/mysql/schemas/commerce/product.d.cts +16 -0
  123. package/dist/lib/mysql/schemas/commerce/product.d.ts +16 -0
  124. package/dist/lib/mysql/schemas/commerce/product.js +10 -11
  125. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs +141 -113
  126. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.cjs.map +1 -1
  127. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.cts +16 -0
  128. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.d.ts +16 -0
  129. package/dist/lib/mysql/schemas/commerce/purchase-user-transfer.js +11 -12
  130. package/dist/lib/mysql/schemas/commerce/purchase.cjs +293 -175
  131. package/dist/lib/mysql/schemas/commerce/purchase.cjs.map +1 -1
  132. package/dist/lib/mysql/schemas/commerce/purchase.d.cts +34 -0
  133. package/dist/lib/mysql/schemas/commerce/purchase.d.ts +34 -0
  134. package/dist/lib/mysql/schemas/commerce/purchase.js +10 -11
  135. package/dist/lib/mysql/schemas/commerce/subscription.cjs +343 -0
  136. package/dist/lib/mysql/schemas/commerce/subscription.cjs.map +1 -0
  137. package/dist/lib/mysql/schemas/commerce/subscription.d.cts +130 -0
  138. package/dist/lib/mysql/schemas/commerce/subscription.d.ts +130 -0
  139. package/dist/lib/mysql/schemas/commerce/subscription.js +20 -0
  140. package/dist/lib/mysql/schemas/commerce/subscription.js.map +1 -0
  141. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs +109 -85
  142. package/dist/lib/mysql/schemas/commerce/upgradable-products.cjs.map +1 -1
  143. package/dist/lib/mysql/schemas/commerce/upgradable-products.d.cts +16 -0
  144. package/dist/lib/mysql/schemas/commerce/upgradable-products.d.ts +16 -0
  145. package/dist/lib/mysql/schemas/commerce/upgradable-products.js +11 -12
  146. package/dist/lib/mysql/schemas/communication/comment.cjs +148 -87
  147. package/dist/lib/mysql/schemas/communication/comment.cjs.map +1 -1
  148. package/dist/lib/mysql/schemas/communication/comment.d.cts +17 -0
  149. package/dist/lib/mysql/schemas/communication/comment.d.ts +17 -0
  150. package/dist/lib/mysql/schemas/communication/comment.js +10 -11
  151. package/dist/lib/mysql/schemas/communication/communication-channel.cjs +5 -1
  152. package/dist/lib/mysql/schemas/communication/communication-channel.cjs.map +1 -1
  153. package/dist/lib/mysql/schemas/communication/communication-channel.d.cts +16 -0
  154. package/dist/lib/mysql/schemas/communication/communication-channel.d.ts +16 -0
  155. package/dist/lib/mysql/schemas/communication/communication-channel.js +1 -1
  156. package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs +3 -0
  157. package/dist/lib/mysql/schemas/communication/communication-preference-types.cjs.map +1 -1
  158. package/dist/lib/mysql/schemas/communication/communication-preference-types.d.cts +16 -0
  159. package/dist/lib/mysql/schemas/communication/communication-preference-types.d.ts +16 -0
  160. package/dist/lib/mysql/schemas/communication/communication-preference-types.js +1 -1
  161. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +176 -105
  162. package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
  163. package/dist/lib/mysql/schemas/communication/communication-preferences.d.cts +33 -0
  164. package/dist/lib/mysql/schemas/communication/communication-preferences.d.ts +33 -0
  165. package/dist/lib/mysql/schemas/communication/communication-preferences.js +10 -11
  166. package/dist/lib/mysql/schemas/content/content-contributions.cjs +186 -111
  167. package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
  168. package/dist/lib/mysql/schemas/content/content-contributions.d.cts +33 -0
  169. package/dist/lib/mysql/schemas/content/content-contributions.d.ts +33 -0
  170. package/dist/lib/mysql/schemas/content/content-contributions.js +10 -11
  171. package/dist/lib/mysql/schemas/content/content-resource-product.cjs +110 -79
  172. package/dist/lib/mysql/schemas/content/content-resource-product.cjs.map +1 -1
  173. package/dist/lib/mysql/schemas/content/content-resource-product.d.cts +16 -0
  174. package/dist/lib/mysql/schemas/content/content-resource-product.d.ts +16 -0
  175. package/dist/lib/mysql/schemas/content/content-resource-product.js +10 -11
  176. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs +115 -88
  177. package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
  178. package/dist/lib/mysql/schemas/content/content-resource-resource.d.cts +16 -0
  179. package/dist/lib/mysql/schemas/content/content-resource-resource.d.ts +16 -0
  180. package/dist/lib/mysql/schemas/content/content-resource-resource.js +10 -11
  181. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs +127 -96
  182. package/dist/lib/mysql/schemas/content/content-resource-tag.cjs.map +1 -1
  183. package/dist/lib/mysql/schemas/content/content-resource-tag.d.cts +16 -0
  184. package/dist/lib/mysql/schemas/content/content-resource-tag.d.ts +16 -0
  185. package/dist/lib/mysql/schemas/content/content-resource-tag.js +10 -11
  186. package/dist/lib/mysql/schemas/content/content-resource-version.cjs +130 -103
  187. package/dist/lib/mysql/schemas/content/content-resource-version.cjs.map +1 -1
  188. package/dist/lib/mysql/schemas/content/content-resource-version.d.cts +16 -0
  189. package/dist/lib/mysql/schemas/content/content-resource-version.d.ts +16 -0
  190. package/dist/lib/mysql/schemas/content/content-resource-version.js +10 -11
  191. package/dist/lib/mysql/schemas/content/content-resource.cjs +248 -157
  192. package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
  193. package/dist/lib/mysql/schemas/content/content-resource.d.cts +33 -0
  194. package/dist/lib/mysql/schemas/content/content-resource.d.ts +33 -0
  195. package/dist/lib/mysql/schemas/content/content-resource.js +10 -11
  196. package/dist/lib/mysql/schemas/content/contribution-types.cjs +5 -1
  197. package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
  198. package/dist/lib/mysql/schemas/content/contribution-types.d.cts +16 -0
  199. package/dist/lib/mysql/schemas/content/contribution-types.d.ts +16 -0
  200. package/dist/lib/mysql/schemas/content/contribution-types.js +1 -1
  201. package/dist/lib/mysql/schemas/content/lesson-progress.cjs +8 -1
  202. package/dist/lib/mysql/schemas/content/lesson-progress.cjs.map +1 -1
  203. package/dist/lib/mysql/schemas/content/lesson-progress.d.cts +32 -0
  204. package/dist/lib/mysql/schemas/content/lesson-progress.d.ts +32 -0
  205. package/dist/lib/mysql/schemas/content/lesson-progress.js +1 -1
  206. package/dist/lib/mysql/schemas/content/resource-progress.cjs +8 -1
  207. package/dist/lib/mysql/schemas/content/resource-progress.cjs.map +1 -1
  208. package/dist/lib/mysql/schemas/content/resource-progress.d.cts +32 -0
  209. package/dist/lib/mysql/schemas/content/resource-progress.d.ts +32 -0
  210. package/dist/lib/mysql/schemas/content/resource-progress.js +1 -1
  211. package/dist/lib/mysql/schemas/content/tag-tag.cjs +108 -84
  212. package/dist/lib/mysql/schemas/content/tag-tag.cjs.map +1 -1
  213. package/dist/lib/mysql/schemas/content/tag-tag.d.cts +16 -0
  214. package/dist/lib/mysql/schemas/content/tag-tag.d.ts +16 -0
  215. package/dist/lib/mysql/schemas/content/tag-tag.js +10 -11
  216. package/dist/lib/mysql/schemas/content/tag.cjs +123 -95
  217. package/dist/lib/mysql/schemas/content/tag.cjs.map +1 -1
  218. package/dist/lib/mysql/schemas/content/tag.d.cts +16 -0
  219. package/dist/lib/mysql/schemas/content/tag.d.ts +16 -0
  220. package/dist/lib/mysql/schemas/content/tag.js +10 -11
  221. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs +301 -0
  222. package/dist/lib/mysql/schemas/org/organization-membership-roles.cjs.map +1 -0
  223. package/dist/lib/mysql/schemas/org/organization-membership-roles.d.cts +129 -0
  224. package/dist/lib/mysql/schemas/org/organization-membership-roles.d.ts +129 -0
  225. package/dist/lib/mysql/schemas/org/organization-membership-roles.js +21 -0
  226. package/dist/lib/mysql/schemas/org/organization-membership-roles.js.map +1 -0
  227. package/dist/lib/mysql/schemas/org/organization-memberships.cjs +370 -0
  228. package/dist/lib/mysql/schemas/org/organization-memberships.cjs.map +1 -0
  229. package/dist/lib/mysql/schemas/org/organization-memberships.d.cts +131 -0
  230. package/dist/lib/mysql/schemas/org/organization-memberships.d.ts +131 -0
  231. package/dist/lib/mysql/schemas/org/organization-memberships.js +20 -0
  232. package/dist/lib/mysql/schemas/org/organization-memberships.js.map +1 -0
  233. package/dist/lib/mysql/schemas/org/organizations.cjs +349 -0
  234. package/dist/lib/mysql/schemas/org/organizations.cjs.map +1 -0
  235. package/dist/lib/mysql/schemas/org/organizations.d.cts +98 -0
  236. package/dist/lib/mysql/schemas/org/organizations.d.ts +98 -0
  237. package/dist/lib/mysql/schemas/org/organizations.js +20 -0
  238. package/dist/lib/mysql/schemas/org/organizations.js.map +1 -0
  239. package/package.json +2 -2
  240. package/src/lib/mysql/index.ts +34 -0
  241. package/src/lib/mysql/schemas/auth/device-access-token.ts +3 -0
  242. package/src/lib/mysql/schemas/auth/roles.ts +3 -0
  243. package/src/lib/mysql/schemas/auth/user-permissions.ts +2 -0
  244. package/src/lib/mysql/schemas/auth/user-prefs.ts +2 -0
  245. package/src/lib/mysql/schemas/auth/user-roles.ts +2 -0
  246. package/src/lib/mysql/schemas/auth/users.ts +5 -0
  247. package/src/lib/mysql/schemas/commerce/coupon.ts +2 -0
  248. package/src/lib/mysql/schemas/commerce/merchant-account.ts +3 -0
  249. package/src/lib/mysql/schemas/commerce/merchant-charge.ts +16 -0
  250. package/src/lib/mysql/schemas/commerce/merchant-coupon.ts +3 -0
  251. package/src/lib/mysql/schemas/commerce/merchant-customer.ts +2 -0
  252. package/src/lib/mysql/schemas/commerce/merchant-price.ts +3 -0
  253. package/src/lib/mysql/schemas/commerce/merchant-product.ts +3 -0
  254. package/src/lib/mysql/schemas/commerce/merchant-session.ts +8 -1
  255. package/src/lib/mysql/schemas/commerce/merchant-subscription.ts +64 -0
  256. package/src/lib/mysql/schemas/commerce/price.ts +3 -0
  257. package/src/lib/mysql/schemas/commerce/product.ts +3 -0
  258. package/src/lib/mysql/schemas/commerce/purchase-user-transfer.ts +3 -0
  259. package/src/lib/mysql/schemas/commerce/purchase.ts +22 -0
  260. package/src/lib/mysql/schemas/commerce/subscription.ts +71 -0
  261. package/src/lib/mysql/schemas/commerce/upgradable-products.ts +2 -0
  262. package/src/lib/mysql/schemas/communication/comment.ts +13 -0
  263. package/src/lib/mysql/schemas/communication/communication-channel.ts +2 -0
  264. package/src/lib/mysql/schemas/communication/communication-preference-types.ts +1 -0
  265. package/src/lib/mysql/schemas/communication/communication-preferences.ts +14 -0
  266. package/src/lib/mysql/schemas/content/content-contributions.ts +14 -0
  267. package/src/lib/mysql/schemas/content/content-resource-product.ts +2 -0
  268. package/src/lib/mysql/schemas/content/content-resource-resource.ts +2 -0
  269. package/src/lib/mysql/schemas/content/content-resource-tag.ts +2 -0
  270. package/src/lib/mysql/schemas/content/content-resource-version.ts +2 -0
  271. package/src/lib/mysql/schemas/content/content-resource.ts +17 -0
  272. package/src/lib/mysql/schemas/content/contribution-types.ts +2 -0
  273. package/src/lib/mysql/schemas/content/lesson-progress.ts +7 -0
  274. package/src/lib/mysql/schemas/content/resource-progress.ts +7 -0
  275. package/src/lib/mysql/schemas/content/tag-tag.ts +2 -0
  276. package/src/lib/mysql/schemas/content/tag.ts +2 -0
  277. package/src/lib/mysql/schemas/org/organization-membership-roles.ts +68 -0
  278. package/src/lib/mysql/schemas/org/organization-memberships.ts +69 -0
  279. package/src/lib/mysql/schemas/org/organizations.ts +50 -0
  280. package/dist/chunk-SRTIWWLG.js +0 -96
@@ -0,0 +1,64 @@
1
+ import { relations, sql } from 'drizzle-orm'
2
+ import {
3
+ index,
4
+ int,
5
+ MySqlTableFn,
6
+ primaryKey,
7
+ timestamp,
8
+ varchar,
9
+ } from 'drizzle-orm/mysql-core'
10
+
11
+ import { getMerchantChargeSchema } from './merchant-charge.js'
12
+ import { getSubscriptionSchema } from './subscription.js'
13
+
14
+ export function getMerchantSubscriptionSchema(mysqlTable: MySqlTableFn) {
15
+ return mysqlTable(
16
+ 'MerchantSubscription',
17
+ {
18
+ id: varchar('id', { length: 191 }).notNull(),
19
+ organizationId: varchar('organizationId', { length: 191 }),
20
+ merchantAccountId: varchar('merchantAccountId', {
21
+ length: 191,
22
+ }).notNull(),
23
+ status: int('status').default(0).notNull(),
24
+ createdAt: timestamp('createdAt', { mode: 'date', fsp: 3 })
25
+ .default(sql`CURRENT_TIMESTAMP(3)`)
26
+ .notNull(),
27
+ label: varchar('label', { length: 191 }),
28
+ identifier: varchar('identifier', { length: 191 }),
29
+ merchantCustomerId: varchar('merchantCustomerId', {
30
+ length: 191,
31
+ }).notNull(),
32
+ merchantProductId: varchar('merchantProductId', {
33
+ length: 191,
34
+ }).notNull(),
35
+ },
36
+ (table) => {
37
+ return {
38
+ merchantSubscriptionId: primaryKey({
39
+ columns: [table.id],
40
+ name: 'MerchantSubscription_id',
41
+ }),
42
+ organizationIdIdx: index('organizationId_idx').on(table.organizationId),
43
+ }
44
+ },
45
+ )
46
+ }
47
+
48
+ export function getMerchantSubscriptionRelationsSchema(
49
+ mysqlTable: MySqlTableFn,
50
+ ) {
51
+ const merchantSubscription = getMerchantSubscriptionSchema(mysqlTable)
52
+ const merchantCharge = getMerchantChargeSchema(mysqlTable)
53
+ const subscription = getSubscriptionSchema(mysqlTable)
54
+ return relations(merchantSubscription, ({ many, one }) => ({
55
+ merchantCharges: many(merchantCharge, {
56
+ relationName: 'merchantSubscription',
57
+ }),
58
+ subscription: one(subscription, {
59
+ fields: [merchantSubscription.id],
60
+ references: [subscription.merchantSubscriptionId],
61
+ relationName: 'subscription',
62
+ }),
63
+ }))
64
+ }
@@ -1,6 +1,7 @@
1
1
  import { relations, sql } from 'drizzle-orm'
2
2
  import {
3
3
  decimal,
4
+ index,
4
5
  int,
5
6
  json,
6
7
  MySqlTableFn,
@@ -18,6 +19,7 @@ export function getPriceSchema(mysqlTable: MySqlTableFn) {
18
19
  {
19
20
  id: varchar('id', { length: 191 }).notNull(),
20
21
  productId: varchar('productId', { length: 191 }),
22
+ organizationId: varchar('organizationId', { length: 191 }),
21
23
  nickname: varchar('nickname', { length: 191 }),
22
24
  status: int('status').default(0).notNull(),
23
25
  unitAmount: decimal('unitAmount', { precision: 10, scale: 2 }).notNull(),
@@ -29,6 +31,7 @@ export function getPriceSchema(mysqlTable: MySqlTableFn) {
29
31
  (table) => {
30
32
  return {
31
33
  priceId: primaryKey({ columns: [table.id], name: 'Price_id' }),
34
+ organizationIdIdx: index('organizationId_idx').on(table.organizationId),
32
35
  }
33
36
  },
34
37
  )
@@ -1,5 +1,6 @@
1
1
  import { relations, sql } from 'drizzle-orm'
2
2
  import {
3
+ index,
3
4
  int,
4
5
  json,
5
6
  MySqlTableFn,
@@ -17,6 +18,7 @@ export function getProductSchema(mysqlTable: MySqlTableFn) {
17
18
  'Product',
18
19
  {
19
20
  id: varchar('id', { length: 191 }).notNull(),
21
+ organizationId: varchar('organizationId', { length: 191 }),
20
22
  name: varchar('name', { length: 191 }).notNull(),
21
23
  key: varchar('key', { length: 191 }),
22
24
  type: varchar('type', { length: 191 }),
@@ -30,6 +32,7 @@ export function getProductSchema(mysqlTable: MySqlTableFn) {
30
32
  (table) => {
31
33
  return {
32
34
  productId: primaryKey({ columns: [table.id], name: 'Product_id' }),
35
+ organizationIdIdx: index('organizationId_idx').on(table.organizationId),
33
36
  }
34
37
  },
35
38
  )
@@ -1,5 +1,6 @@
1
1
  import { relations, sql } from 'drizzle-orm'
2
2
  import {
3
+ index,
3
4
  mysqlEnum,
4
5
  MySqlTableFn,
5
6
  primaryKey,
@@ -27,6 +28,7 @@ export function getPurchaseUserTransferSchema(mysqlTable: MySqlTableFn) {
27
28
  .default('AVAILABLE')
28
29
  .notNull(),
29
30
  purchaseId: varchar('purchaseId', { length: 191 }).notNull(),
31
+ organizationId: varchar('organizationId', { length: 191 }),
30
32
  sourceUserId: varchar('sourceUserId', { length: 191 }).notNull(),
31
33
  targetUserId: varchar('targetUserId', { length: 191 }),
32
34
  createdAt: timestamp('createdAt', { mode: 'date', fsp: 3 })
@@ -43,6 +45,7 @@ export function getPurchaseUserTransferSchema(mysqlTable: MySqlTableFn) {
43
45
  columns: [table.id],
44
46
  name: 'PurchaseUserTransfer_id',
45
47
  }),
48
+ organizationIdIdx: index('organizationId_idx').on(table.organizationId),
46
49
  }
47
50
  },
48
51
  )
@@ -11,6 +11,8 @@ import {
11
11
  } from 'drizzle-orm/mysql-core'
12
12
 
13
13
  import { getUsersSchema } from '../auth/users.js'
14
+ import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
15
+ import { getOrganizationsSchema } from '../org/organizations.js'
14
16
  import { getCouponSchema } from './coupon.js'
15
17
  import { getMerchantChargeSchema } from './merchant-charge.js'
16
18
  import { getMerchantSessionSchema } from './merchant-session.js'
@@ -22,6 +24,10 @@ export function getPurchaseSchema(mysqlTable: MySqlTableFn) {
22
24
  {
23
25
  id: varchar('id', { length: 191 }).notNull(),
24
26
  userId: varchar('userId', { length: 191 }),
27
+ purchasedByorganizationMembershipId: varchar('organizationMembershipId', {
28
+ length: 191,
29
+ }),
30
+ organizationId: varchar('organizationId', { length: 191 }),
25
31
  createdAt: timestamp('createdAt', { mode: 'date', fsp: 3 })
26
32
  .default(sql`CURRENT_TIMESTAMP(3)`)
27
33
  .notNull(),
@@ -52,6 +58,10 @@ export function getPurchaseSchema(mysqlTable: MySqlTableFn) {
52
58
  purchaseUpgradedFromIdKey: unique('Purchase_upgradedFromId_key').on(
53
59
  table.upgradedFromId,
54
60
  ),
61
+ organizationIdIdx: index('organizationId_idx').on(table.organizationId),
62
+ organizationMembershipIdIdx: index('organizationMembershipId_idx').on(
63
+ table.purchasedByorganizationMembershipId,
64
+ ),
55
65
  }
56
66
  },
57
67
  )
@@ -64,6 +74,8 @@ export function getPurchaseRelationsSchema(mysqlTable: MySqlTableFn) {
64
74
  const merchantCharges = getMerchantChargeSchema(mysqlTable)
65
75
  const merchantSessions = getMerchantSessionSchema(mysqlTable)
66
76
  const coupons = getCouponSchema(mysqlTable)
77
+ const organizations = getOrganizationsSchema(mysqlTable)
78
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
67
79
 
68
80
  return relations(purchases, ({ many, one }) => ({
69
81
  redeemedBulkCoupon: one(coupons, {
@@ -76,6 +88,16 @@ export function getPurchaseRelationsSchema(mysqlTable: MySqlTableFn) {
76
88
  references: [users.id],
77
89
  relationName: 'user',
78
90
  }),
91
+ organization: one(organizations, {
92
+ fields: [purchases.organizationId],
93
+ references: [organizations.id],
94
+ relationName: 'organization',
95
+ }),
96
+ purchasedBy: one(organizationMemberships, {
97
+ fields: [purchases.purchasedByorganizationMembershipId],
98
+ references: [organizationMemberships.id],
99
+ relationName: 'organizationMembership',
100
+ }),
79
101
  product: one(products, {
80
102
  fields: [purchases.productId],
81
103
  references: [products.id],
@@ -0,0 +1,71 @@
1
+ import { relations, sql } from 'drizzle-orm'
2
+ import {
3
+ index,
4
+ json,
5
+ MySqlTableFn,
6
+ primaryKey,
7
+ timestamp,
8
+ varchar,
9
+ } from 'drizzle-orm/mysql-core'
10
+
11
+ import { getUsersSchema } from '../auth/users.js'
12
+ import { getOrganizationsSchema } from '../org/organizations.js'
13
+ import { getCouponSchema } from './coupon.js'
14
+ import { getMerchantChargeSchema } from './merchant-charge.js'
15
+ import { getMerchantSessionSchema } from './merchant-session.js'
16
+ import { getMerchantSubscriptionSchema } from './merchant-subscription.js'
17
+ import { getProductSchema } from './product.js'
18
+
19
+ export function getSubscriptionSchema(mysqlTable: MySqlTableFn) {
20
+ return mysqlTable(
21
+ 'Subscription',
22
+ {
23
+ id: varchar('id', { length: 191 }).notNull(),
24
+ organizationId: varchar('organizationId', { length: 191 }),
25
+ productId: varchar('productId', { length: 191 }).notNull(),
26
+ createdAt: timestamp('createdAt', { mode: 'date', fsp: 3 })
27
+ .default(sql`CURRENT_TIMESTAMP(3)`)
28
+ .notNull(),
29
+ merchantSubscriptionId: varchar('merchantSubscriptionId', {
30
+ length: 191,
31
+ }).notNull(),
32
+ status: varchar('status', { length: 191 }).default('Valid').notNull(),
33
+ fields: json('fields').$type<Record<string, any>>().default({}),
34
+ },
35
+ (table) => {
36
+ return {
37
+ subscriptionId: primaryKey({
38
+ columns: [table.id],
39
+ name: 'Subscription_id',
40
+ }),
41
+ organizationIdIdx: index('organizationId_idx').on(table.organizationId),
42
+ }
43
+ },
44
+ )
45
+ }
46
+
47
+ export function getSubscriptionRelationsSchema(mysqlTable: MySqlTableFn) {
48
+ const subscriptions = getSubscriptionSchema(mysqlTable)
49
+ const products = getProductSchema(mysqlTable)
50
+
51
+ const organizations = getOrganizationsSchema(mysqlTable)
52
+ const merchantSubscriptions = getMerchantSubscriptionSchema(mysqlTable)
53
+
54
+ return relations(subscriptions, ({ many, one }) => ({
55
+ organization: one(organizations, {
56
+ fields: [subscriptions.organizationId],
57
+ references: [organizations.id],
58
+ relationName: 'organization',
59
+ }),
60
+ product: one(products, {
61
+ fields: [subscriptions.productId],
62
+ references: [products.id],
63
+ relationName: 'product',
64
+ }),
65
+ merchantSubscription: one(merchantSubscriptions, {
66
+ fields: [subscriptions.merchantSubscriptionId],
67
+ references: [merchantSubscriptions.id],
68
+ relationName: 'merchantSubscription',
69
+ }),
70
+ }))
71
+ }
@@ -17,6 +17,7 @@ export function getUpgradableProductsSchema(mysqlTable: MySqlTableFn) {
17
17
  {
18
18
  upgradableToId: varchar('upgradableToId', { length: 255 }).notNull(),
19
19
  upgradableFromId: varchar('upgradableFrom', { length: 255 }).notNull(),
20
+ organizationId: varchar('organizationId', { length: 191 }),
20
21
  position: double('position').notNull().default(0),
21
22
  metadata: json('metadata').$type<Record<string, any>>().default({}),
22
23
  createdAt: timestamp('createdAt', {
@@ -36,6 +37,7 @@ export function getUpgradableProductsSchema(mysqlTable: MySqlTableFn) {
36
37
  pk: primaryKey({ columns: [crr.upgradableToId, crr.upgradableFromId] }),
37
38
  upgradableToIdIdx: index('upgradableFromId_idx').on(crr.upgradableToId),
38
39
  upgradableFromIdIdx: index('upgradableToId_idx').on(crr.upgradableFromId),
40
+ organizationIdIdx: index('organizationId_idx').on(crr.organizationId),
39
41
  }),
40
42
  )
41
43
  }
@@ -10,6 +10,7 @@ import {
10
10
  } from 'drizzle-orm/mysql-core'
11
11
 
12
12
  import { getUsersSchema } from '../auth/users.js'
13
+ import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
13
14
 
14
15
  export function getCommentsSchema(mysqlTable: MySqlTableFn) {
15
16
  return mysqlTable(
@@ -17,6 +18,9 @@ export function getCommentsSchema(mysqlTable: MySqlTableFn) {
17
18
  {
18
19
  id: varchar('id', { length: 191 }).notNull(),
19
20
  userId: varchar('userId', { length: 255 }).notNull(),
21
+ organizationMembershipId: varchar('organizationMembershipId', {
22
+ length: 255,
23
+ }),
20
24
  context: json('context').$type<Record<string, any>>().default({}),
21
25
  text: text('text').notNull(),
22
26
  createdAt: timestamp('createdAt', {
@@ -35,6 +39,9 @@ export function getCommentsSchema(mysqlTable: MySqlTableFn) {
35
39
  (crr) => ({
36
40
  pk: primaryKey({ columns: [crr.id] }),
37
41
  crrUserIdIdKey: index('crr_userIdId_idx').on(crr.userId),
42
+ organizationMembershipIdIdx: index('organizationMembershipId_idx').on(
43
+ crr.organizationMembershipId,
44
+ ),
38
45
  }),
39
46
  )
40
47
  }
@@ -42,11 +49,17 @@ export function getCommentsSchema(mysqlTable: MySqlTableFn) {
42
49
  export function getCommentRelationsSchema(mysqlTable: MySqlTableFn) {
43
50
  const comment = getCommentsSchema(mysqlTable)
44
51
  const user = getUsersSchema(mysqlTable)
52
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
45
53
  return relations(comment, ({ one }) => ({
46
54
  user: one(user, {
47
55
  fields: [comment.userId],
48
56
  references: [user.id],
49
57
  relationName: 'user',
50
58
  }),
59
+ organizationMembership: one(organizationMemberships, {
60
+ fields: [comment.organizationMembershipId],
61
+ references: [organizationMemberships.id],
62
+ relationName: 'organizationMembership',
63
+ }),
51
64
  }))
52
65
  }
@@ -12,6 +12,7 @@ export function getCommunicationChannelSchema(mysqlTable: MySqlTableFn) {
12
12
  'CommunicationChannel',
13
13
  {
14
14
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
15
+ organizationId: varchar('organizationId', { length: 191 }),
15
16
  name: varchar('name', { length: 255 }).notNull(),
16
17
  description: text('description'),
17
18
  active: boolean('active').notNull().default(true),
@@ -30,6 +31,7 @@ export function getCommunicationChannelSchema(mysqlTable: MySqlTableFn) {
30
31
  },
31
32
  (cc) => ({
32
33
  nameIdx: index('name_idx').on(cc.name),
34
+ organizationIdIdx: index('organizationId_idx').on(cc.organizationId),
33
35
  }),
34
36
  )
35
37
  }
@@ -11,6 +11,7 @@ export function getCommunicationPreferenceTypesSchema(
11
11
  ) {
12
12
  return mysqlTable('CommunicationPreferenceType', {
13
13
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
14
+ organizationId: varchar('organizationId', { length: 191 }),
14
15
  name: varchar('name', { length: 255 }).notNull(),
15
16
  description: text('description'),
16
17
  active: boolean('active').notNull().default(true),
@@ -9,6 +9,7 @@ import {
9
9
  } from 'drizzle-orm/mysql-core'
10
10
 
11
11
  import { getUsersSchema } from '../auth/users.js'
12
+ import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
12
13
  import { getCommunicationChannelSchema } from './communication-channel.js'
13
14
  import { getCommunicationPreferenceTypesSchema } from './communication-preference-types.js'
14
15
 
@@ -17,7 +18,11 @@ export function getCommunicationPreferencesSchema(mysqlTable: MySqlTableFn) {
17
18
  'CommunicationPreference',
18
19
  {
19
20
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
21
+ organizationId: varchar('organizationId', { length: 191 }),
20
22
  userId: varchar('userId', { length: 255 }).notNull(),
23
+ organizationMembershipId: varchar('organizationMembershipId', {
24
+ length: 255,
25
+ }),
21
26
  channelId: varchar('channelId', { length: 255 }).notNull(),
22
27
  preferenceLevel: mysqlEnum('preferenceLevel', ['low', 'medium', 'high'])
23
28
  .notNull()
@@ -49,6 +54,9 @@ export function getCommunicationPreferencesSchema(mysqlTable: MySqlTableFn) {
49
54
  userIdIdx: index('userId_idx').on(cp.userId),
50
55
  preferenceTypeIdx: index('preferenceTypeId_idx').on(cp.preferenceTypeId),
51
56
  channelIdIdx: index('channelId_idx').on(cp.channelId),
57
+ organizationMembershipIdIdx: index('organizationMembershipId_idx').on(
58
+ cp.organizationMembershipId,
59
+ ),
52
60
  }),
53
61
  )
54
62
  }
@@ -61,12 +69,18 @@ export function getCommunicationPreferencesRelationsSchema(
61
69
  const communicationChannel = getCommunicationChannelSchema(mysqlTable)
62
70
  const communicationPreferenceTypes =
63
71
  getCommunicationPreferenceTypesSchema(mysqlTable)
72
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
64
73
  return relations(communicationPreferences, ({ one }) => ({
65
74
  user: one(users, {
66
75
  fields: [communicationPreferences.userId],
67
76
  references: [users.id],
68
77
  relationName: 'user',
69
78
  }),
79
+ organizationMembership: one(organizationMemberships, {
80
+ fields: [communicationPreferences.organizationMembershipId],
81
+ references: [organizationMemberships.id],
82
+ relationName: 'organizationMembership',
83
+ }),
70
84
  channel: one(communicationChannel, {
71
85
  fields: [communicationPreferences.channelId],
72
86
  references: [communicationChannel.id],
@@ -8,6 +8,7 @@ import {
8
8
  } from 'drizzle-orm/mysql-core'
9
9
 
10
10
  import { getUsersSchema } from '../auth/users.js'
11
+ import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
11
12
  import { getContentResourceSchema } from './content-resource.js'
12
13
  import { getContributionTypesSchema } from './contribution-types.js'
13
14
 
@@ -17,6 +18,10 @@ export function getContentContributionsSchema(mysqlTable: MySqlTableFn) {
17
18
  {
18
19
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
19
20
  userId: varchar('userId', { length: 255 }).notNull(),
21
+ organizationId: varchar('organizationId', { length: 191 }),
22
+ organizationMembershipId: varchar('organizationMembershipId', {
23
+ length: 255,
24
+ }),
20
25
  contentId: varchar('contentId', { length: 255 }).notNull(),
21
26
  contributionTypeId: varchar('contributionTypeId', {
22
27
  length: 255,
@@ -41,6 +46,9 @@ export function getContentContributionsSchema(mysqlTable: MySqlTableFn) {
41
46
  contributionTypeIdIdx: index('contributionTypeId_idx').on(
42
47
  cc.contributionTypeId,
43
48
  ),
49
+ organizationMembershipIdIdx: index('organizationMembershipId_idx').on(
50
+ cc.organizationMembershipId,
51
+ ),
44
52
  }),
45
53
  )
46
54
  }
@@ -52,6 +60,7 @@ export function getContentContributionRelationsSchema(
52
60
  const users = getUsersSchema(mysqlTable)
53
61
  const contentResource = getContentResourceSchema(mysqlTable)
54
62
  const contributionTypes = getContributionTypesSchema(mysqlTable)
63
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
55
64
 
56
65
  return relations(contentContributions, ({ one }) => ({
57
66
  user: one(users, {
@@ -69,5 +78,10 @@ export function getContentContributionRelationsSchema(
69
78
  references: [contributionTypes.id],
70
79
  relationName: 'contributionType',
71
80
  }),
81
+ organizationMembership: one(organizationMemberships, {
82
+ fields: [contentContributions.organizationMembershipId],
83
+ references: [organizationMemberships.id],
84
+ relationName: 'organizationMembership',
85
+ }),
72
86
  }))
73
87
  }
@@ -18,6 +18,7 @@ export function getContentResourceProductSchema(mysqlTable: MySqlTableFn) {
18
18
  {
19
19
  productId: varchar('productId', { length: 255 }).notNull(),
20
20
  resourceId: varchar('resourceId', { length: 255 }).notNull(),
21
+ organizationId: varchar('organizationId', { length: 191 }),
21
22
  position: double('position').notNull().default(0),
22
23
  metadata: json('metadata').$type<Record<string, any>>().default({}),
23
24
  createdAt: timestamp('createdAt', {
@@ -37,6 +38,7 @@ export function getContentResourceProductSchema(mysqlTable: MySqlTableFn) {
37
38
  pk: primaryKey({ columns: [crr.productId, crr.resourceId] }),
38
39
  contentResourceIdIdx: index('contentResourceId_idx').on(crr.productId),
39
40
  resourceIdIdx: index('resourceId_idx').on(crr.resourceId),
41
+ organizationIdIdx: index('organizationId_idx').on(crr.organizationId),
40
42
  }),
41
43
  )
42
44
  }
@@ -19,6 +19,7 @@ export function getContentResourceResourceSchema(mysqlTable: MySqlTableFn) {
19
19
  resourceId: varchar('resourceId', { length: 255 }).notNull(),
20
20
  position: double('position').notNull().default(0),
21
21
  metadata: json('metadata').$type<Record<string, any>>().default({}),
22
+ organizationId: varchar('organizationId', { length: 191 }),
22
23
  createdAt: timestamp('createdAt', {
23
24
  mode: 'date',
24
25
  fsp: 3,
@@ -36,6 +37,7 @@ export function getContentResourceResourceSchema(mysqlTable: MySqlTableFn) {
36
37
  pk: primaryKey({ columns: [crr.resourceOfId, crr.resourceId] }),
37
38
  contentResourceIdIdx: index('contentResourceId_idx').on(crr.resourceOfId),
38
39
  resourceIdIdx: index('resourceId_idx').on(crr.resourceId),
40
+ organizationIdIdx: index('organizationId_idx').on(crr.organizationId),
39
41
  }),
40
42
  )
41
43
  }
@@ -18,6 +18,7 @@ export function getContentResourceTagSchema(mysqlTable: MySqlTableFn) {
18
18
  contentResourceId: varchar('contentResourceId', {
19
19
  length: 255,
20
20
  }).notNull(),
21
+ organizationId: varchar('organizationId', { length: 191 }),
21
22
  tagId: varchar('tagId', { length: 255 }).notNull(),
22
23
  position: double('position').notNull().default(0),
23
24
  createdAt: timestamp('createdAt', {
@@ -36,6 +37,7 @@ export function getContentResourceTagSchema(mysqlTable: MySqlTableFn) {
36
37
  ),
37
38
  tagIdIdx: index('tagId_idx').on(crt.tagId),
38
39
  positionIdx: index('position_idx').on(crt.position),
40
+ organizationIdIdx: index('organizationId_idx').on(crt.organizationId),
39
41
  }),
40
42
  )
41
43
  }
@@ -17,6 +17,7 @@ export function getContentResourceVersionSchema(mysqlTable: MySqlTableFn) {
17
17
  'ContentResourceVersion',
18
18
  {
19
19
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
20
+ organizationId: varchar('organizationId', { length: 191 }),
20
21
  resourceId: varchar('resourceId', { length: 255 }).notNull(),
21
22
  parentVersionId: varchar('parentVersionId', { length: 255 }),
22
23
  versionNumber: int('versionNumber').notNull(),
@@ -38,6 +39,7 @@ export function getContentResourceVersionSchema(mysqlTable: MySqlTableFn) {
38
39
  crv.resourceId,
39
40
  crv.versionNumber,
40
41
  ),
42
+ organizationIdIdx: index('organizationId_idx').on(crv.organizationId),
41
43
  }),
42
44
  )
43
45
  }
@@ -8,6 +8,7 @@ import {
8
8
  } from 'drizzle-orm/mysql-core'
9
9
 
10
10
  import { getUsersSchema } from '../auth/users.js'
11
+ import { getOrganizationMembershipsSchema } from '../org/organization-memberships.js'
11
12
  import { getContentContributionsSchema } from './content-contributions.js'
12
13
  import { getContentResourceProductSchema } from './content-resource-product.js'
13
14
  import { getContentResourceResourceSchema } from './content-resource-resource.js'
@@ -20,6 +21,13 @@ export function getContentResourceSchema(mysqlTable: MySqlTableFn) {
20
21
  'ContentResource',
21
22
  {
22
23
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
24
+ organizationId: varchar('organizationId', { length: 191 }),
25
+ createdByOrganizationMembershipId: varchar(
26
+ 'createdByOrganizationMembershipId',
27
+ {
28
+ length: 191,
29
+ },
30
+ ),
23
31
  type: varchar('type', { length: 255 }).notNull(),
24
32
  createdById: varchar('createdById', { length: 255 }).notNull(),
25
33
  fields: json('fields').$type<Record<string, any>>().default({}),
@@ -44,6 +52,9 @@ export function getContentResourceSchema(mysqlTable: MySqlTableFn) {
44
52
  currentVersionIdIdx: index('currentVersionId_idx').on(
45
53
  cm.currentVersionId,
46
54
  ),
55
+ createdByOrganizationMembershipIdIdx: index(
56
+ 'createdByOrganizationMembershipId_idx',
57
+ ).on(cm.createdByOrganizationMembershipId),
47
58
  }),
48
59
  )
49
60
  }
@@ -56,6 +67,7 @@ export function getContentResourceRelationsSchema(mysqlTable: MySqlTableFn) {
56
67
  const contentContributions = getContentContributionsSchema(mysqlTable)
57
68
  const contentResourceTag = getContentResourceTagSchema(mysqlTable)
58
69
  const contentResourceVersion = getContentResourceVersionSchema(mysqlTable)
70
+ const organizationMemberships = getOrganizationMembershipsSchema(mysqlTable)
59
71
  const tag = getTagSchema(mysqlTable)
60
72
  return relations(contentResource, ({ one, many }) => ({
61
73
  createdBy: one(users, {
@@ -63,6 +75,11 @@ export function getContentResourceRelationsSchema(mysqlTable: MySqlTableFn) {
63
75
  references: [users.id],
64
76
  relationName: 'creator',
65
77
  }),
78
+ createdByOrganizationMembership: one(organizationMemberships, {
79
+ fields: [contentResource.createdByOrganizationMembershipId],
80
+ references: [organizationMemberships.id],
81
+ relationName: 'createdByOrganizationMembership',
82
+ }),
66
83
  tags: many(contentResourceTag, { relationName: 'contentResource' }),
67
84
  resources: many(contentResourceResource, { relationName: 'resourceOf' }),
68
85
  resourceOf: many(contentResourceResource, { relationName: 'resource' }),
@@ -15,6 +15,7 @@ export function getContributionTypesSchema(mysqlTable: MySqlTableFn) {
15
15
  'ContributionType',
16
16
  {
17
17
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
18
+ organizationId: varchar('organizationId', { length: 191 }),
18
19
  slug: varchar('slug', { length: 255 }).notNull().unique(),
19
20
  name: varchar('name', { length: 255 }).notNull(),
20
21
  description: text('description'),
@@ -35,6 +36,7 @@ export function getContributionTypesSchema(mysqlTable: MySqlTableFn) {
35
36
  (ct) => ({
36
37
  nameIdx: index('name_idx').on(ct.name),
37
38
  slugIdx: index('slug_idx').on(ct.slug),
39
+ organizationIdIdx: index('organizationId_idx').on(ct.organizationId),
38
40
  }),
39
41
  )
40
42
  }
@@ -14,6 +14,10 @@ export function getLessonProgressSchema(mysqlTable: MySqlTableFn) {
14
14
  {
15
15
  id: varchar('id', { length: 191 }).notNull().primaryKey(),
16
16
  userId: varchar('userId', { length: 191 }).notNull(),
17
+ organizationId: varchar('organizationId', { length: 191 }),
18
+ organizationMembershipId: varchar('organizationMembershipId', {
19
+ length: 191,
20
+ }),
17
21
  lessonId: varchar('lessonId', { length: 191 }),
18
22
  lessonSlug: varchar('lessonSlug', { length: 191 }),
19
23
  lessonVersion: varchar('lessonVersion', { length: 191 }),
@@ -33,6 +37,9 @@ export function getLessonProgressSchema(mysqlTable: MySqlTableFn) {
33
37
  ),
34
38
  userIdIdx: index('userId_idx').on(crp.userId),
35
39
  lessonIdIdx: index('lessonId_idx').on(crp.lessonId),
40
+ organizationMembershipIdIdx: index('organizationMembershipId_idx').on(
41
+ crp.organizationMembershipId,
42
+ ),
36
43
  }
37
44
  },
38
45
  )
@@ -13,6 +13,10 @@ export function getResourceProgressSchema(mysqlTable: MySqlTableFn) {
13
13
  'ResourceProgress',
14
14
  {
15
15
  userId: varchar('userId', { length: 255 }).notNull(),
16
+ organizationId: varchar('organizationId', { length: 191 }),
17
+ organizationMembershipId: varchar('organizationMembershipId', {
18
+ length: 191,
19
+ }),
16
20
  resourceId: varchar('resourceId', { length: 255 }),
17
21
  fields: json('fields').$type<Record<string, any>>().default({}),
18
22
  completedAt: datetime('completedAt', { mode: 'date', fsp: 3 }),
@@ -30,6 +34,9 @@ export function getResourceProgressSchema(mysqlTable: MySqlTableFn) {
30
34
  pk: primaryKey({ columns: [crp.userId, crp.resourceId] }),
31
35
  contentResourceIdIdx: index('contentResourceId_idx').on(crp.resourceId),
32
36
  userIdIdx: index('resourceId_idx').on(crp.userId),
37
+ organizationMembershipIdIdx: index('organizationMembershipId_idx').on(
38
+ crp.organizationMembershipId,
39
+ ),
33
40
  }
34
41
  },
35
42
  )
@@ -19,6 +19,7 @@ export function getTagTagSchema(mysqlTable: MySqlTableFn) {
19
19
  childTagId: varchar('childTagId', { length: 255 }).notNull(),
20
20
  position: double('position').notNull().default(0),
21
21
  metadata: json('metadata').$type<Record<string, any>>().default({}),
22
+ organizationId: varchar('organizationId', { length: 191 }),
22
23
  createdAt: timestamp('createdAt', {
23
24
  mode: 'date',
24
25
  fsp: 3,
@@ -37,6 +38,7 @@ export function getTagTagSchema(mysqlTable: MySqlTableFn) {
37
38
  parentTagIdIdx: index('parentTagId_idx').on(tt.parentTagId),
38
39
  childTagIdIdx: index('childTagId_idx').on(tt.childTagId),
39
40
  positionIdx: index('position_idx').on(tt.position),
41
+ organizationIdIdx: index('organizationId_idx').on(tt.organizationId),
40
42
  }),
41
43
  )
42
44
  }
@@ -15,6 +15,7 @@ export function getTagSchema(mysqlTable: MySqlTableFn) {
15
15
  'Tag',
16
16
  {
17
17
  id: varchar('id', { length: 255 }).notNull().primaryKey(),
18
+ organizationId: varchar('organizationId', { length: 191 }),
18
19
  type: varchar('type', { length: 255 }).notNull(),
19
20
  fields: json('fields').$type<Record<string, any>>().default({}),
20
21
  createdAt: timestamp('createdAt', {
@@ -32,6 +33,7 @@ export function getTagSchema(mysqlTable: MySqlTableFn) {
32
33
  },
33
34
  (t) => ({
34
35
  typeIdx: index('type_idx').on(t.type),
36
+ organizationIdIdx: index('organizationId_idx').on(t.organizationId),
35
37
  }),
36
38
  )
37
39
  }