@payloadcms/db-postgres 3.0.0-canary.6041f49 → 3.0.0-canary.6d066c2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (400) hide show
  1. package/README.md +1 -1
  2. package/dist/connect.d.ts +1 -1
  3. package/dist/connect.d.ts.map +1 -1
  4. package/dist/connect.js +16 -13
  5. package/dist/connect.js.map +1 -1
  6. package/dist/countDistinct.d.ts +3 -0
  7. package/dist/countDistinct.d.ts.map +1 -0
  8. package/dist/countDistinct.js +24 -0
  9. package/dist/countDistinct.js.map +1 -0
  10. package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -0
  11. package/dist/createJSONQuery/convertPathToJSONTraversal.js.map +1 -0
  12. package/dist/createJSONQuery/formatJSONPathSegment.d.ts.map +1 -0
  13. package/dist/createJSONQuery/formatJSONPathSegment.js.map +1 -0
  14. package/dist/createJSONQuery/index.d.ts.map +1 -0
  15. package/dist/createJSONQuery/index.js.map +1 -0
  16. package/dist/createMigration.d.ts +1 -1
  17. package/dist/createMigration.d.ts.map +1 -1
  18. package/dist/createMigration.js +56 -57
  19. package/dist/createMigration.js.map +1 -1
  20. package/dist/defaultSnapshot.d.ts +3 -0
  21. package/dist/defaultSnapshot.d.ts.map +1 -0
  22. package/dist/defaultSnapshot.js +16 -0
  23. package/dist/defaultSnapshot.js.map +1 -0
  24. package/dist/deleteWhere.d.ts +3 -0
  25. package/dist/deleteWhere.d.ts.map +1 -0
  26. package/dist/deleteWhere.js +6 -0
  27. package/dist/deleteWhere.js.map +1 -0
  28. package/dist/dropDatabase.d.ts +3 -0
  29. package/dist/dropDatabase.d.ts.map +1 -0
  30. package/dist/dropDatabase.js +9 -0
  31. package/dist/dropDatabase.js.map +1 -0
  32. package/dist/execute.d.ts +3 -0
  33. package/dist/execute.d.ts.map +1 -0
  34. package/dist/execute.js +11 -0
  35. package/dist/execute.js.map +1 -0
  36. package/dist/exports/migration-utils.d.ts +2 -0
  37. package/dist/exports/migration-utils.d.ts.map +1 -0
  38. package/dist/exports/migration-utils.js +3 -0
  39. package/dist/exports/migration-utils.js.map +1 -0
  40. package/dist/getMigrationTemplate.d.ts +3 -0
  41. package/dist/getMigrationTemplate.d.ts.map +1 -0
  42. package/dist/getMigrationTemplate.js +12 -0
  43. package/dist/getMigrationTemplate.js.map +1 -0
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +37 -64
  47. package/dist/index.js.map +1 -1
  48. package/dist/init.d.ts +1 -1
  49. package/dist/init.d.ts.map +1 -1
  50. package/dist/init.js +17 -22
  51. package/dist/init.js.map +1 -1
  52. package/dist/insert.d.ts +3 -0
  53. package/dist/insert.d.ts.map +1 -0
  54. package/dist/insert.js +12 -0
  55. package/dist/insert.js.map +1 -0
  56. package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
  57. package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
  58. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
  59. package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
  60. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +20 -0
  61. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
  62. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +169 -0
  63. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
  64. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
  65. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
  66. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +191 -0
  67. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
  68. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
  69. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
  70. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
  71. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
  72. package/dist/predefinedMigrations/v2-v3/index.d.ts +23 -0
  73. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
  74. package/dist/predefinedMigrations/v2-v3/index.js +211 -0
  75. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
  76. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +20 -0
  77. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
  78. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
  79. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
  80. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +23 -0
  81. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
  82. package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
  83. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
  84. package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
  85. package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
  86. package/dist/predefinedMigrations/v2-v3/types.js +6 -0
  87. package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
  88. package/dist/requireDrizzleKit.d.ts +3 -0
  89. package/dist/requireDrizzleKit.d.ts.map +1 -0
  90. package/dist/requireDrizzleKit.js +5 -0
  91. package/dist/requireDrizzleKit.js.map +1 -0
  92. package/dist/schema/build.d.ts +9 -5
  93. package/dist/schema/build.d.ts.map +1 -1
  94. package/dist/schema/build.js +163 -114
  95. package/dist/schema/build.js.map +1 -1
  96. package/dist/schema/createIndex.js.map +1 -1
  97. package/dist/schema/idToUUID.d.ts +1 -1
  98. package/dist/schema/idToUUID.d.ts.map +1 -1
  99. package/dist/schema/idToUUID.js.map +1 -1
  100. package/dist/schema/parentIDColumnMap.js.map +1 -1
  101. package/dist/schema/setColumnID.d.ts +1 -1
  102. package/dist/schema/setColumnID.d.ts.map +1 -1
  103. package/dist/schema/setColumnID.js +2 -2
  104. package/dist/schema/setColumnID.js.map +1 -1
  105. package/dist/schema/traverseFields.d.ts +5 -7
  106. package/dist/schema/traverseFields.d.ts.map +1 -1
  107. package/dist/schema/traverseFields.js +107 -46
  108. package/dist/schema/traverseFields.js.map +1 -1
  109. package/dist/types.d.ts +78 -32
  110. package/dist/types.d.ts.map +1 -1
  111. package/dist/types.js.map +1 -1
  112. package/package.json +22 -13
  113. package/dist/count.d.ts +0 -3
  114. package/dist/count.d.ts.map +0 -1
  115. package/dist/count.js +0 -50
  116. package/dist/count.js.map +0 -1
  117. package/dist/create.d.ts +0 -3
  118. package/dist/create.d.ts.map +0 -1
  119. package/dist/create.js +0 -19
  120. package/dist/create.js.map +0 -1
  121. package/dist/createGlobal.d.ts +0 -5
  122. package/dist/createGlobal.d.ts.map +0 -1
  123. package/dist/createGlobal.js +0 -19
  124. package/dist/createGlobal.js.map +0 -1
  125. package/dist/createGlobalVersion.d.ts +0 -6
  126. package/dist/createGlobalVersion.d.ts.map +0 -1
  127. package/dist/createGlobalVersion.js +0 -33
  128. package/dist/createGlobalVersion.js.map +0 -1
  129. package/dist/createVersion.d.ts +0 -5
  130. package/dist/createVersion.d.ts.map +0 -1
  131. package/dist/createVersion.js +0 -44
  132. package/dist/createVersion.js.map +0 -1
  133. package/dist/deleteMany.d.ts +0 -3
  134. package/dist/deleteMany.d.ts.map +0 -1
  135. package/dist/deleteMany.js +0 -28
  136. package/dist/deleteMany.js.map +0 -1
  137. package/dist/deleteOne.d.ts +0 -3
  138. package/dist/deleteOne.d.ts.map +0 -1
  139. package/dist/deleteOne.js +0 -59
  140. package/dist/deleteOne.js.map +0 -1
  141. package/dist/deleteVersions.d.ts +0 -3
  142. package/dist/deleteVersions.d.ts.map +0 -1
  143. package/dist/deleteVersions.js +0 -31
  144. package/dist/deleteVersions.js.map +0 -1
  145. package/dist/destroy.d.ts +0 -3
  146. package/dist/destroy.d.ts.map +0 -1
  147. package/dist/destroy.js +0 -11
  148. package/dist/destroy.js.map +0 -1
  149. package/dist/find/buildFindManyArgs.d.ts +0 -13
  150. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  151. package/dist/find/buildFindManyArgs.js +0 -64
  152. package/dist/find/buildFindManyArgs.js.map +0 -1
  153. package/dist/find/chainMethods.d.ts +0 -16
  154. package/dist/find/chainMethods.d.ts.map +0 -1
  155. package/dist/find/chainMethods.js +0 -12
  156. package/dist/find/chainMethods.js.map +0 -1
  157. package/dist/find/findMany.d.ts +0 -22
  158. package/dist/find/findMany.d.ts.map +0 -1
  159. package/dist/find/findMany.js +0 -163
  160. package/dist/find/findMany.js.map +0 -1
  161. package/dist/find/traverseFields.d.ts +0 -16
  162. package/dist/find/traverseFields.d.ts.map +0 -1
  163. package/dist/find/traverseFields.js +0 -138
  164. package/dist/find/traverseFields.js.map +0 -1
  165. package/dist/find.d.ts +0 -3
  166. package/dist/find.d.ts.map +0 -1
  167. package/dist/find.js +0 -21
  168. package/dist/find.js.map +0 -1
  169. package/dist/findGlobal.d.ts +0 -3
  170. package/dist/findGlobal.d.ts.map +0 -1
  171. package/dist/findGlobal.js +0 -23
  172. package/dist/findGlobal.js.map +0 -1
  173. package/dist/findGlobalVersions.d.ts +0 -3
  174. package/dist/findGlobalVersions.d.ts.map +0 -1
  175. package/dist/findGlobalVersions.js +0 -24
  176. package/dist/findGlobalVersions.js.map +0 -1
  177. package/dist/findOne.d.ts +0 -5
  178. package/dist/findOne.d.ts.map +0 -1
  179. package/dist/findOne.js +0 -21
  180. package/dist/findOne.js.map +0 -1
  181. package/dist/findVersions.d.ts +0 -3
  182. package/dist/findVersions.d.ts.map +0 -1
  183. package/dist/findVersions.js +0 -24
  184. package/dist/findVersions.js.map +0 -1
  185. package/dist/migrate.d.ts +0 -3
  186. package/dist/migrate.d.ts.map +0 -1
  187. package/dist/migrate.js +0 -99
  188. package/dist/migrate.js.map +0 -1
  189. package/dist/migrateDown.d.ts +0 -3
  190. package/dist/migrateDown.d.ts.map +0 -1
  191. package/dist/migrateDown.js +0 -63
  192. package/dist/migrateDown.js.map +0 -1
  193. package/dist/migrateFresh.d.ts +0 -8
  194. package/dist/migrateFresh.d.ts.map +0 -1
  195. package/dist/migrateFresh.js +0 -72
  196. package/dist/migrateFresh.js.map +0 -1
  197. package/dist/migrateRefresh.d.ts +0 -6
  198. package/dist/migrateRefresh.d.ts.map +0 -1
  199. package/dist/migrateRefresh.js +0 -102
  200. package/dist/migrateRefresh.js.map +0 -1
  201. package/dist/migrateReset.d.ts +0 -6
  202. package/dist/migrateReset.d.ts.map +0 -1
  203. package/dist/migrateReset.js +0 -82
  204. package/dist/migrateReset.js.map +0 -1
  205. package/dist/migrateStatus.d.ts +0 -3
  206. package/dist/migrateStatus.d.ts.map +0 -1
  207. package/dist/migrateStatus.js +0 -44
  208. package/dist/migrateStatus.js.map +0 -1
  209. package/dist/queries/buildAndOrConditions.d.ts +0 -17
  210. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  211. package/dist/queries/buildAndOrConditions.js +0 -29
  212. package/dist/queries/buildAndOrConditions.js.map +0 -1
  213. package/dist/queries/buildQuery.d.ts +0 -31
  214. package/dist/queries/buildQuery.d.ts.map +0 -1
  215. package/dist/queries/buildQuery.js +0 -76
  216. package/dist/queries/buildQuery.js.map +0 -1
  217. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  218. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  219. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  220. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  221. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  222. package/dist/queries/createJSONQuery/index.js.map +0 -1
  223. package/dist/queries/getTableColumnFromPath.d.ts +0 -51
  224. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  225. package/dist/queries/getTableColumnFromPath.js +0 -445
  226. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  227. package/dist/queries/operatorMap.d.ts +0 -18
  228. package/dist/queries/operatorMap.d.ts.map +0 -1
  229. package/dist/queries/operatorMap.js +0 -24
  230. package/dist/queries/operatorMap.js.map +0 -1
  231. package/dist/queries/parseParams.d.ts +0 -17
  232. package/dist/queries/parseParams.d.ts.map +0 -1
  233. package/dist/queries/parseParams.js +0 -182
  234. package/dist/queries/parseParams.js.map +0 -1
  235. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  236. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  237. package/dist/queries/sanitizeQueryValue.js +0 -90
  238. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  239. package/dist/queries/selectDistinct.d.ts +0 -23
  240. package/dist/queries/selectDistinct.d.ts.map +0 -1
  241. package/dist/queries/selectDistinct.js +0 -41
  242. package/dist/queries/selectDistinct.js.map +0 -1
  243. package/dist/queryDrafts.d.ts +0 -3
  244. package/dist/queryDrafts.d.ts.map +0 -1
  245. package/dist/queryDrafts.js +0 -41
  246. package/dist/queryDrafts.js.map +0 -1
  247. package/dist/schema/createTableName.d.ts +0 -30
  248. package/dist/schema/createTableName.d.ts.map +0 -1
  249. package/dist/schema/createTableName.js +0 -31
  250. package/dist/schema/createTableName.js.map +0 -1
  251. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
  252. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  253. package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
  254. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  255. package/dist/transactions/beginTransaction.d.ts +0 -3
  256. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  257. package/dist/transactions/beginTransaction.js +0 -47
  258. package/dist/transactions/beginTransaction.js.map +0 -1
  259. package/dist/transactions/commitTransaction.d.ts +0 -3
  260. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  261. package/dist/transactions/commitTransaction.js +0 -14
  262. package/dist/transactions/commitTransaction.js.map +0 -1
  263. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  264. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  265. package/dist/transactions/rollbackTransaction.js +0 -13
  266. package/dist/transactions/rollbackTransaction.js.map +0 -1
  267. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  268. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  269. package/dist/transform/read/hasManyNumber.js +0 -10
  270. package/dist/transform/read/hasManyNumber.js.map +0 -1
  271. package/dist/transform/read/hasManyText.d.ts +0 -10
  272. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  273. package/dist/transform/read/hasManyText.js +0 -10
  274. package/dist/transform/read/hasManyText.js.map +0 -1
  275. package/dist/transform/read/index.d.ts +0 -12
  276. package/dist/transform/read/index.d.ts.map +0 -1
  277. package/dist/transform/read/index.js +0 -43
  278. package/dist/transform/read/index.js.map +0 -1
  279. package/dist/transform/read/relationship.d.ts +0 -10
  280. package/dist/transform/read/relationship.d.ts.map +0 -1
  281. package/dist/transform/read/relationship.js +0 -64
  282. package/dist/transform/read/relationship.js.map +0 -1
  283. package/dist/transform/read/traverseFields.d.ts +0 -52
  284. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  285. package/dist/transform/read/traverseFields.js +0 -421
  286. package/dist/transform/read/traverseFields.js.map +0 -1
  287. package/dist/transform/write/array.d.ts +0 -26
  288. package/dist/transform/write/array.d.ts.map +0 -1
  289. package/dist/transform/write/array.js +0 -58
  290. package/dist/transform/write/array.js.map +0 -1
  291. package/dist/transform/write/blocks.d.ts +0 -25
  292. package/dist/transform/write/blocks.d.ts.map +0 -1
  293. package/dist/transform/write/blocks.js +0 -54
  294. package/dist/transform/write/blocks.js.map +0 -1
  295. package/dist/transform/write/index.d.ts +0 -13
  296. package/dist/transform/write/index.d.ts.map +0 -1
  297. package/dist/transform/write/index.js +0 -41
  298. package/dist/transform/write/index.js.map +0 -1
  299. package/dist/transform/write/numbers.d.ts +0 -8
  300. package/dist/transform/write/numbers.d.ts.map +0 -1
  301. package/dist/transform/write/numbers.js +0 -11
  302. package/dist/transform/write/numbers.js.map +0 -1
  303. package/dist/transform/write/relationships.d.ts +0 -10
  304. package/dist/transform/write/relationships.d.ts.map +0 -1
  305. package/dist/transform/write/relationships.js +0 -23
  306. package/dist/transform/write/relationships.js.map +0 -1
  307. package/dist/transform/write/selects.d.ts +0 -8
  308. package/dist/transform/write/selects.d.ts.map +0 -1
  309. package/dist/transform/write/selects.js +0 -20
  310. package/dist/transform/write/selects.js.map +0 -1
  311. package/dist/transform/write/texts.d.ts +0 -8
  312. package/dist/transform/write/texts.d.ts.map +0 -1
  313. package/dist/transform/write/texts.js +0 -11
  314. package/dist/transform/write/texts.js.map +0 -1
  315. package/dist/transform/write/traverseFields.d.ts +0 -50
  316. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  317. package/dist/transform/write/traverseFields.js +0 -428
  318. package/dist/transform/write/traverseFields.js.map +0 -1
  319. package/dist/transform/write/types.d.ts +0 -43
  320. package/dist/transform/write/types.d.ts.map +0 -1
  321. package/dist/transform/write/types.js +0 -3
  322. package/dist/transform/write/types.js.map +0 -1
  323. package/dist/update.d.ts +0 -3
  324. package/dist/update.d.ts.map +0 -1
  325. package/dist/update.js +0 -55
  326. package/dist/update.js.map +0 -1
  327. package/dist/updateGlobal.d.ts +0 -5
  328. package/dist/updateGlobal.d.ts.map +0 -1
  329. package/dist/updateGlobal.js +0 -25
  330. package/dist/updateGlobal.js.map +0 -1
  331. package/dist/updateGlobalVersion.d.ts +0 -5
  332. package/dist/updateGlobalVersion.d.ts.map +0 -1
  333. package/dist/updateGlobalVersion.js +0 -36
  334. package/dist/updateGlobalVersion.js.map +0 -1
  335. package/dist/updateVersion.d.ts +0 -5
  336. package/dist/updateVersion.d.ts.map +0 -1
  337. package/dist/updateVersion.js +0 -36
  338. package/dist/updateVersion.js.map +0 -1
  339. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  340. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  341. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  342. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  343. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  344. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  345. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  346. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  347. package/dist/upsertRow/index.d.ts +0 -4
  348. package/dist/upsertRow/index.d.ts.map +0 -1
  349. package/dist/upsertRow/index.js +0 -277
  350. package/dist/upsertRow/index.js.map +0 -1
  351. package/dist/upsertRow/insertArrays.d.ts +0 -13
  352. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  353. package/dist/upsertRow/insertArrays.js +0 -68
  354. package/dist/upsertRow/insertArrays.js.map +0 -1
  355. package/dist/upsertRow/types.d.ts +0 -27
  356. package/dist/upsertRow/types.d.ts.map +0 -1
  357. package/dist/upsertRow/types.js +0 -3
  358. package/dist/upsertRow/types.js.map +0 -1
  359. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  360. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  361. package/dist/utilities/appendPrefixToKeys.js +0 -6
  362. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  363. package/dist/utilities/createBlocksMap.d.ts +0 -5
  364. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  365. package/dist/utilities/createBlocksMap.js +0 -29
  366. package/dist/utilities/createBlocksMap.js.map +0 -1
  367. package/dist/utilities/createMigrationTable.d.ts +0 -3
  368. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  369. package/dist/utilities/createMigrationTable.js +0 -13
  370. package/dist/utilities/createMigrationTable.js.map +0 -1
  371. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  372. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  373. package/dist/utilities/createRelationshipMap.js +0 -19
  374. package/dist/utilities/createRelationshipMap.js.map +0 -1
  375. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  376. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  377. package/dist/utilities/hasLocalesTable.js +0 -11
  378. package/dist/utilities/hasLocalesTable.js.map +0 -1
  379. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  380. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  381. package/dist/utilities/isArrayOfRows.js +0 -5
  382. package/dist/utilities/isArrayOfRows.js.map +0 -1
  383. package/dist/utilities/migrationTableExists.d.ts +0 -3
  384. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  385. package/dist/utilities/migrationTableExists.js +0 -9
  386. package/dist/utilities/migrationTableExists.js.map +0 -1
  387. package/dist/utilities/parseError.d.ts +0 -5
  388. package/dist/utilities/parseError.d.ts.map +0 -1
  389. package/dist/utilities/parseError.js +0 -17
  390. package/dist/utilities/parseError.js.map +0 -1
  391. package/dist/utilities/pushDevSchema.d.ts +0 -9
  392. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  393. package/dist/utilities/pushDevSchema.js +0 -58
  394. package/dist/utilities/pushDevSchema.js.map +0 -1
  395. /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.d.ts +0 -0
  396. /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.js +0 -0
  397. /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.d.ts +0 -0
  398. /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.js +0 -0
  399. /package/dist/{queries/createJSONQuery → createJSONQuery}/index.d.ts +0 -0
  400. /package/dist/{queries/createJSONQuery → createJSONQuery}/index.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/migrateRelationships.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\nimport type { Field, Payload, PayloadRequest } from 'payload'\n\nimport { sql } from 'drizzle-orm'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { DocsToResave, PathsToQuery } from './types.js'\n\nimport { fetchAndResave } from './fetchAndResave/index.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n db: TransactionPg\n debug: boolean\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n pathsToQuery: PathsToQuery\n payload: Payload\n req?: Partial<PayloadRequest>\n tableName: string\n}\n\nexport const migrateRelationships = async ({\n adapter,\n collectionSlug,\n db,\n debug,\n fields,\n globalSlug,\n isVersions,\n pathsToQuery,\n payload,\n req,\n tableName,\n}: Args) => {\n if (pathsToQuery.size === 0) return\n\n let offset = 0\n\n let paginationResult\n\n const where = Array.from(pathsToQuery).reduce((statement, path, i) => {\n return (statement += `\n\"${tableName}${adapter.relationshipsSuffix}\".\"path\" LIKE '${path}'${pathsToQuery.size !== i + 1 ? ' OR' : ''}\n`)\n }, '')\n\n while (typeof paginationResult === 'undefined' || paginationResult.rows.length > 0) {\n const paginationStatement = `SELECT DISTINCT parent_id FROM ${tableName}${adapter.relationshipsSuffix} WHERE\n ${where} ORDER BY parent_id LIMIT 500 OFFSET ${offset * 500};\n `\n\n paginationResult = await adapter.drizzle.execute(sql.raw(`${paginationStatement}`))\n\n if (paginationResult.rows.length === 0) return\n\n offset += 1\n\n const statement = `SELECT * FROM ${tableName}${adapter.relationshipsSuffix} WHERE\n (${where}) AND parent_id IN (${paginationResult.rows.map((row) => row.parent_id).join(', ')});\n`\n if (debug) {\n payload.logger.info('FINDING ROWS TO MIGRATE')\n payload.logger.info(statement)\n }\n\n const result = await adapter.drizzle.execute(sql.raw(`${statement}`))\n\n const docsToResave: DocsToResave = {}\n\n result.rows.forEach((row) => {\n const parentID = row.parent_id\n\n if (typeof parentID === 'string' || typeof parentID === 'number') {\n if (!docsToResave[parentID]) docsToResave[parentID] = []\n docsToResave[parentID].push(row)\n }\n })\n\n await fetchAndResave({\n adapter,\n collectionSlug,\n db,\n debug,\n docsToResave,\n fields,\n globalSlug,\n isVersions,\n payload,\n req: req as unknown as PayloadRequest,\n tableName,\n })\n }\n\n const deleteStatement = `DELETE FROM ${tableName}${adapter.relationshipsSuffix} WHERE ${where}`\n if (debug) {\n payload.logger.info('DELETING ROWS')\n payload.logger.info(deleteStatement)\n }\n await db.execute(sql.raw(`${deleteStatement}`))\n}\n"],"names":["sql","fetchAndResave","migrateRelationships","adapter","collectionSlug","db","debug","fields","globalSlug","isVersions","pathsToQuery","payload","req","tableName","size","offset","paginationResult","where","Array","from","reduce","statement","path","i","relationshipsSuffix","rows","length","paginationStatement","drizzle","execute","raw","map","row","parent_id","join","logger","info","result","docsToResave","forEach","parentID","push","deleteStatement"],"mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AAKjC,SAASC,cAAc,QAAQ,4BAA2B;AAgB1D,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,OAAO,EACPC,cAAc,EACdC,EAAE,EACFC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,OAAO,EACPC,GAAG,EACHC,SAAS,EACJ;IACL,IAAIH,aAAaI,IAAI,KAAK,GAAG;IAE7B,IAAIC,SAAS;IAEb,IAAIC;IAEJ,MAAMC,QAAQC,MAAMC,IAAI,CAACT,cAAcU,MAAM,CAAC,CAACC,WAAWC,MAAMC;QAC9D,OAAQF,aAAa,CAAC;CACzB,EAAER,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC,eAAe,EAAEF,KAAK,CAAC,EAAEZ,aAAaI,IAAI,KAAKS,IAAI,IAAI,QAAQ,GAAG;AAC7G,CAAC;IACC,GAAG;IAEH,MAAO,OAAOP,qBAAqB,eAAeA,iBAAiBS,IAAI,CAACC,MAAM,GAAG,EAAG;QAClF,MAAMC,sBAAsB,CAAC,+BAA+B,EAAEd,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC;IACtG,EAAEP,MAAM,qCAAqC,EAAEF,SAAS,IAAI;EAC9D,CAAC;QAECC,mBAAmB,MAAMb,QAAQyB,OAA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AAEY,gBAAgB,CAAC;AAC/C,EAAC"}
@@ -0,0 +1,23 @@
1
+ import type { TransactionPg } from '@payloadcms/drizzle/types';
2
+ import type { Field, Payload } from 'payload';
3
+ import type { PostgresAdapter } from '../../types.js';
4
+ import type { PathsToQuery } from './types.js';
5
+ type Args = {
6
+ adapter: PostgresAdapter;
7
+ collectionSlug?: string;
8
+ columnPrefix: string;
9
+ db: TransactionPg;
10
+ disableNotNull: boolean;
11
+ fields: Field[];
12
+ globalSlug?: string;
13
+ isVersions: boolean;
14
+ newTableName: string;
15
+ parentTableName: string;
16
+ path: string;
17
+ pathsToQuery: PathsToQuery;
18
+ payload: Payload;
19
+ rootTableName: string;
20
+ };
21
+ export declare const traverseFields: (args: Args) => void;
22
+ export {};
23
+ //# sourceMappingURL=traverseFields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAK7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,EAAE,EAAE,aAAa,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,SAAU,IAAI,SA0FxC,CAAA"}
@@ -0,0 +1,85 @@
1
+ import { tabHasName } from 'payload/shared';
2
+ import toSnakeCase from 'to-snake-case';
3
+ export const traverseFields = (args)=>{
4
+ args.fields.forEach((field)=>{
5
+ switch(field.type){
6
+ case 'group':
7
+ {
8
+ let newTableName = `${args.newTableName}_${toSnakeCase(field.name)}`;
9
+ if (field.localized && args.payload.config.localization) {
10
+ newTableName += args.adapter.localesSuffix;
11
+ }
12
+ return traverseFields({
13
+ ...args,
14
+ columnPrefix: `${args.columnPrefix}${toSnakeCase(field.name)}_`,
15
+ fields: field.fields,
16
+ newTableName,
17
+ path: `${args.path ? `${args.path}.` : ''}${field.name}`
18
+ });
19
+ }
20
+ case 'row':
21
+ case 'collapsible':
22
+ {
23
+ return traverseFields({
24
+ ...args,
25
+ fields: field.fields
26
+ });
27
+ }
28
+ case 'array':
29
+ {
30
+ const newTableName = args.adapter.tableNameMap.get(`${args.newTableName}_${toSnakeCase(field.name)}`);
31
+ return traverseFields({
32
+ ...args,
33
+ columnPrefix: '',
34
+ fields: field.fields,
35
+ newTableName,
36
+ parentTableName: newTableName,
37
+ path: `${args.path ? `${args.path}.` : ''}${field.name}.%`
38
+ });
39
+ }
40
+ case 'blocks':
41
+ {
42
+ return field.blocks.forEach((block)=>{
43
+ const newTableName = args.adapter.tableNameMap.get(`${args.rootTableName}_blocks_${toSnakeCase(block.slug)}`);
44
+ traverseFields({
45
+ ...args,
46
+ columnPrefix: '',
47
+ fields: block.fields,
48
+ newTableName,
49
+ parentTableName: newTableName,
50
+ path: `${args.path ? `${args.path}.` : ''}${field.name}.%`
51
+ });
52
+ });
53
+ }
54
+ case 'tabs':
55
+ {
56
+ return field.tabs.forEach((tab)=>{
57
+ if (tabHasName(tab)) {
58
+ args.columnPrefix = `${args.columnPrefix}_${toSnakeCase(tab.name)}_`;
59
+ args.path = `${args.path ? `${args.path}.` : ''}${tab.name}`;
60
+ args.newTableName = `${args.newTableName}_${toSnakeCase(tab.name)}`;
61
+ if (tab.localized && args.payload.config.localization) {
62
+ args.newTableName += args.adapter.localesSuffix;
63
+ }
64
+ }
65
+ traverseFields({
66
+ ...args,
67
+ fields: tab.fields
68
+ });
69
+ });
70
+ }
71
+ case 'relationship':
72
+ case 'upload':
73
+ {
74
+ if (typeof field.relationTo === 'string') {
75
+ if (field.type === 'upload' || !field.hasMany) {
76
+ args.pathsToQuery.add(`${args.path ? `${args.path}.` : ''}${field.name}`);
77
+ }
78
+ }
79
+ return null;
80
+ }
81
+ }
82
+ });
83
+ };
84
+
85
+ //# sourceMappingURL=traverseFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/traverseFields.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\nimport type { Field, Payload } from 'payload'\n\nimport { tabHasName } from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { PathsToQuery } from './types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n columnPrefix: string\n db: TransactionPg\n disableNotNull: boolean\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n newTableName: string\n parentTableName: string\n path: string\n pathsToQuery: PathsToQuery\n payload: Payload\n rootTableName: string\n}\n\nexport const traverseFields = (args: Args) => {\n args.fields.forEach((field) => {\n switch (field.type) {\n case 'group': {\n let newTableName = `${args.newTableName}_${toSnakeCase(field.name)}`\n\n if (field.localized && args.payload.config.localization) {\n newTableName += args.adapter.localesSuffix\n }\n\n return traverseFields({\n ...args,\n columnPrefix: `${args.columnPrefix}${toSnakeCase(field.name)}_`,\n fields: field.fields,\n newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}`,\n })\n }\n\n case 'row':\n case 'collapsible': {\n return traverseFields({\n ...args,\n fields: field.fields,\n })\n }\n\n case 'array': {\n const newTableName = args.adapter.tableNameMap.get(\n `${args.newTableName}_${toSnakeCase(field.name)}`,\n )\n\n return traverseFields({\n ...args,\n columnPrefix: '',\n fields: field.fields,\n newTableName,\n parentTableName: newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}.%`,\n })\n }\n\n case 'blocks': {\n return field.blocks.forEach((block) => {\n const newTableName = args.adapter.tableNameMap.get(\n `${args.rootTableName}_blocks_${toSnakeCase(block.slug)}`,\n )\n\n traverseFields({\n ...args,\n columnPrefix: '',\n fields: block.fields,\n newTableName,\n parentTableName: newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}.%`,\n })\n })\n }\n\n case 'tabs': {\n return field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n args.columnPrefix = `${args.columnPrefix}_${toSnakeCase(tab.name)}_`\n args.path = `${args.path ? `${args.path}.` : ''}${tab.name}`\n args.newTableName = `${args.newTableName}_${toSnakeCase(tab.name)}`\n\n if (tab.localized && args.payload.config.localization) {\n args.newTableName += args.adapter.localesSuffix\n }\n }\n\n traverseFields({\n ...args,\n fields: tab.fields,\n })\n })\n }\n\n case 'relationship':\n case 'upload': {\n if (typeof field.relationTo === 'string') {\n if (field.type === 'upload' || !field.hasMany) {\n args.pathsToQuery.add(`${args.path ? `${args.path}.` : ''}${field.name}`)\n }\n }\n\n return null\n }\n }\n })\n}\n"],"names":["tabHasName","toSnakeCase","traverseFields","args","fields","forEach","field","type","newTableName","name","localized","payload","config","localization","adapter","localesSuffix","columnPrefix","path","tableNameMap","get","parentTableName","blocks","block","rootTableName","slug","tabs","tab","relationTo","hasMany","pathsToQuery","add"],"mappings":"AAGA,SAASA,UAAU,QAAQ,iBAAgB;AAC3C,OAAOC,iBAAiB,gBAAe;AAsBvC,OAAO,MAAMC,iBAAiB,CAACC;IAC7BA,KAAKC,MAAM,CAACC,OAAO,CAAC,CAACC;QACnB,OAAQA,MAAMC,IAAI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7CzB,KAAK0B,YAAY,CAACC,GAAG,CAAC,CAAC,EAAE3B,KAAKc,IAAI,GAAG,CAAC,EAAEd,KAAKc,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,EAAEX,MAAMG,IAAI,CAAC,CAAC;wBAC1E;oBACF;oBAEA,OAAO;gBACT;QACF;IACF;AACF,EAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Set of all paths which should be moved
3
+ * This will be built up into one WHERE query
4
+ */
5
+ export type PathsToQuery = Set<string>;
6
+ export type DocsToResave = {
7
+ [id: number | string]: Record<string, unknown>[];
8
+ };
9
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;AAEtC,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACjD,CAAA"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Set of all paths which should be moved
3
+ * This will be built up into one WHERE query
4
+ */ export { };
5
+
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/types.ts"],"sourcesContent":["/**\n * Set of all paths which should be moved\n * This will be built up into one WHERE query\n */\nexport type PathsToQuery = Set<string>\n\nexport type DocsToResave = {\n [id: number | string]: Record<string, unknown>[]\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAGD,WAEC"}
@@ -0,0 +1,3 @@
1
+ import type { RequireDrizzleKit } from '@payloadcms/drizzle/types';
2
+ export declare const requireDrizzleKit: RequireDrizzleKit;
3
+ //# sourceMappingURL=requireDrizzleKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireDrizzleKit.d.ts","sourceRoot":"","sources":["../src/requireDrizzleKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAIlE,eAAO,MAAM,iBAAiB,EAAE,iBAAwD,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'module';
2
+ const require = createRequire(import.meta.url);
3
+ export const requireDrizzleKit = ()=>require('drizzle-kit/payload');
4
+
5
+ //# sourceMappingURL=requireDrizzleKit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/requireDrizzleKit.ts"],"sourcesContent":["import type { RequireDrizzleKit } from '@payloadcms/drizzle/types'\n\nimport { createRequire } from 'module'\nconst require = createRequire(import.meta.url)\nexport const requireDrizzleKit: RequireDrizzleKit = () => require('drizzle-kit/payload')\n"],"names":["createRequire","require","url","requireDrizzleKit"],"mappings":"AAEA,SAASA,aAAa,QAAQ,SAAQ;AACtC,MAAMC,UAAUD,cAAc,YAAYE,GAAG;AAC7C,OAAO,MAAMC,oBAAuC,IAAMF,QAAQ,uBAAsB"}
@@ -1,18 +1,22 @@
1
1
  import type { ForeignKeyBuilder, IndexBuilder, PgColumnBuilder, UniqueConstraintBuilder } from 'drizzle-orm/pg-core';
2
- import type { Field } from 'payload/types';
2
+ import type { Field } from 'payload';
3
3
  import type { GenericColumns, PostgresAdapter } from '../types.js';
4
4
  export type BaseExtraConfig = Record<string, (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder>;
5
+ export type RelationMap = Map<string, {
6
+ localized: boolean;
7
+ target: string;
8
+ type: 'many' | 'one';
9
+ }>;
5
10
  type Args = {
6
11
  adapter: PostgresAdapter;
7
12
  baseColumns?: Record<string, PgColumnBuilder>;
8
13
  baseExtraConfig?: BaseExtraConfig;
9
14
  buildNumbers?: boolean;
10
15
  buildRelationships?: boolean;
11
- buildTexts?: boolean;
12
16
  disableNotNull: boolean;
13
17
  disableUnique: boolean;
14
18
  fields: Field[];
15
- rootRelationsToBuild?: Map<string, string>;
19
+ rootRelationsToBuild?: RelationMap;
16
20
  rootRelationships?: Set<string>;
17
21
  rootTableIDColType?: string;
18
22
  rootTableName?: string;
@@ -23,8 +27,8 @@ type Args = {
23
27
  type Result = {
24
28
  hasManyNumberField: 'index' | boolean;
25
29
  hasManyTextField: 'index' | boolean;
26
- relationsToBuild: Map<string, string>;
30
+ relationsToBuild: RelationMap;
27
31
  };
28
- export declare const buildTable: ({ adapter, baseColumns, baseExtraConfig, buildNumbers, buildRelationships, buildTexts, disableNotNull, disableUnique, fields, rootRelationsToBuild, rootRelationships, rootTableIDColType, rootTableName: incomingRootTableName, tableName, timestamps, versions, }: Args) => Result;
32
+ export declare const buildTable: ({ adapter, baseColumns, baseExtraConfig, disableNotNull, disableUnique, fields, rootRelationsToBuild, rootRelationships, rootTableIDColType, rootTableName: incomingRootTableName, tableName, timestamps, versions, }: Args) => Result;
29
33
  export {};
30
34
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/schema/build.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAEf,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAe1C,OAAO,KAAK,EAAE,cAAc,EAAwB,eAAe,EAAE,MAAM,aAAa,CAAA;AAOxF,MAAM,MAAM,eAAe,GAAG,MAAM,CAClC,MAAM,EACN,CAAC,IAAI,EAAE,cAAc,KAAK,iBAAiB,GAAG,YAAY,GAAG,uBAAuB,CACrF,CAAA;AAED,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC7C,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,YAAY,CAA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SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,CAAC,CAAA;AAEnG,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC7C,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;IACtB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,oBAAoB,CAAC,EAAE,WAAW,CAAA;IAClC,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,MAAM,GAAG;IACZ,kBAAkB,EAAE,OAAO,GAAG,OAAO,CAAA;IACrC,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAA;IACnC,gBAAgB,EAAE,WAAW,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,UAAU,0NAcpB,IAAI,KAAG,MAqYT,CAAA"}
@@ -1,11 +1,12 @@
1
- /* eslint-disable no-param-reassign */ import { relations } from 'drizzle-orm';
1
+ /* eslint-disable no-param-reassign */ import { createTableName } from '@payloadcms/drizzle';
2
+ import { relations } from 'drizzle-orm';
2
3
  import { foreignKey, index, integer, numeric, serial, timestamp, unique, varchar } from 'drizzle-orm/pg-core';
3
4
  import toSnakeCase from 'to-snake-case';
4
- import { createTableName } from './createTableName.js';
5
5
  import { parentIDColumnMap } from './parentIDColumnMap.js';
6
6
  import { setColumnID } from './setColumnID.js';
7
7
  import { traverseFields } from './traverseFields.js';
8
- export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, buildNumbers, buildRelationships, buildTexts, disableNotNull, disableUnique = false, fields, rootRelationsToBuild, rootRelationships, rootTableIDColType, rootTableName: incomingRootTableName, tableName, timestamps, versions })=>{
8
+ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, disableNotNull, disableUnique = false, fields, rootRelationsToBuild, rootRelationships, rootTableIDColType, rootTableName: incomingRootTableName, tableName, timestamps, versions })=>{
9
+ const isRoot = !incomingRootTableName;
9
10
  const rootTableName = incomingRootTableName || tableName;
10
11
  const columns = baseColumns;
11
12
  const indexes = {};
@@ -26,9 +27,6 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
26
27
  });
27
28
  const { hasLocalizedField, hasLocalizedManyNumberField, hasLocalizedManyTextField, hasLocalizedRelationshipField, hasManyNumberField, hasManyTextField } = traverseFields({
28
29
  adapter,
29
- buildNumbers,
30
- buildRelationships,
31
- buildTexts,
32
30
  columns,
33
31
  disableNotNull,
34
32
  disableUnique,
@@ -45,6 +43,16 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
45
43
  rootTableName,
46
44
  versions
47
45
  });
46
+ // split the relationsToBuild by localized and non-localized
47
+ const localizedRelations = new Map();
48
+ const nonLocalizedRelations = new Map();
49
+ relationsToBuild.forEach(({ type, localized, target }, key)=>{
50
+ const map = localized ? localizedRelations : nonLocalizedRelations;
51
+ map.set(key, {
52
+ type,
53
+ target
54
+ });
55
+ });
48
56
  if (timestamps) {
49
57
  columns.createdAt = timestamp('created_at', {
50
58
  mode: 'string',
@@ -69,7 +77,7 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
69
77
  return result;
70
78
  });
71
79
  adapter.tables[tableName] = table;
72
- if (hasLocalizedField) {
80
+ if (hasLocalizedField || localizedRelations.size) {
73
81
  const localeTableName = `${tableName}${adapter.localesSuffix}`;
74
82
  localesColumns.id = serial('id').primaryKey();
75
83
  localesColumns._locale = adapter.enums.enum__locales('_locale').notNull();
@@ -92,111 +100,132 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
92
100
  });
93
101
  });
94
102
  adapter.tables[localeTableName] = localesTable;
95
- const localesTableRelations = relations(localesTable, ({ one })=>({
96
- _parentID: one(table, {
97
- fields: [
98
- localesTable._parentID
99
- ],
100
- references: [
101
- table.id
102
- ]
103
- })
104
- }));
105
- adapter.relations[`relations_${localeTableName}`] = localesTableRelations;
103
+ adapter.relations[`relations_${localeTableName}`] = relations(localesTable, ({ many, one })=>{
104
+ const result = {};
105
+ result._parentID = one(table, {
106
+ fields: [
107
+ localesTable._parentID
108
+ ],
109
+ references: [
110
+ table.id
111
+ ],
112
+ // name the relationship by what the many() relationName is
113
+ relationName: '_locales'
114
+ });
115
+ localizedRelations.forEach(({ type, target }, key)=>{
116
+ if (type === 'one') {
117
+ result[key] = one(adapter.tables[target], {
118
+ fields: [
119
+ localesTable[key]
120
+ ],
121
+ references: [
122
+ adapter.tables[target].id
123
+ ],
124
+ relationName: key
125
+ });
126
+ }
127
+ if (type === 'many') {
128
+ result[key] = many(adapter.tables[target], {
129
+ relationName: key
130
+ });
131
+ }
132
+ });
133
+ return result;
134
+ });
106
135
  }
107
- if (hasManyTextField && buildTexts) {
108
- const textsTableName = `${rootTableName}_texts`;
109
- const columns = {
110
- id: serial('id').primaryKey(),
111
- order: integer('order').notNull(),
112
- parent: parentIDColumnMap[idColType]('parent_id').notNull(),
113
- path: varchar('path').notNull(),
114
- text: varchar('text')
115
- };
116
- if (hasLocalizedManyTextField) {
117
- columns.locale = adapter.enums.enum__locales('locale');
118
- }
119
- textsTable = adapter.pgSchema.table(textsTableName, columns, (cols)=>{
120
- const config = {
121
- orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent),
122
- parentFk: foreignKey({
123
- name: `${textsTableName}_parent_fk`,
124
- columns: [
125
- cols.parent
126
- ],
127
- foreignColumns: [
128
- table.id
129
- ]
130
- }).onDelete('cascade')
136
+ if (isRoot) {
137
+ if (hasManyTextField) {
138
+ const textsTableName = `${rootTableName}_texts`;
139
+ const columns = {
140
+ id: serial('id').primaryKey(),
141
+ order: integer('order').notNull(),
142
+ parent: parentIDColumnMap[idColType]('parent_id').notNull(),
143
+ path: varchar('path').notNull(),
144
+ text: varchar('text')
131
145
  };
132
- if (hasManyTextField === 'index') {
133
- config.text_idx = index(`${textsTableName}_text_idx`).on(cols.text);
134
- }
135
146
  if (hasLocalizedManyTextField) {
136
- config.localeParent = index(`${textsTableName}_locale_parent`).on(cols.locale, cols.parent);
147
+ columns.locale = adapter.enums.enum__locales('locale');
137
148
  }
138
- return config;
139
- });
140
- adapter.tables[textsTableName] = textsTable;
141
- const textsTableRelations = relations(textsTable, ({ one })=>({
142
- parent: one(table, {
143
- fields: [
144
- textsTable.parent
145
- ],
146
- references: [
147
- table.id
148
- ]
149
- })
150
- }));
151
- adapter.relations[`relations_${textsTableName}`] = textsTableRelations;
152
- }
153
- if (hasManyNumberField && buildNumbers) {
154
- const numbersTableName = `${rootTableName}_numbers`;
155
- const columns = {
156
- id: serial('id').primaryKey(),
157
- number: numeric('number'),
158
- order: integer('order').notNull(),
159
- parent: parentIDColumnMap[idColType]('parent_id').notNull(),
160
- path: varchar('path').notNull()
161
- };
162
- if (hasLocalizedManyNumberField) {
163
- columns.locale = adapter.enums.enum__locales('locale');
149
+ textsTable = adapter.pgSchema.table(textsTableName, columns, (cols)=>{
150
+ const config = {
151
+ orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent),
152
+ parentFk: foreignKey({
153
+ name: `${textsTableName}_parent_fk`,
154
+ columns: [
155
+ cols.parent
156
+ ],
157
+ foreignColumns: [
158
+ table.id
159
+ ]
160
+ }).onDelete('cascade')
161
+ };
162
+ if (hasManyTextField === 'index') {
163
+ config.text_idx = index(`${textsTableName}_text_idx`).on(cols.text);
164
+ }
165
+ if (hasLocalizedManyTextField) {
166
+ config.localeParent = index(`${textsTableName}_locale_parent`).on(cols.locale, cols.parent);
167
+ }
168
+ return config;
169
+ });
170
+ adapter.tables[textsTableName] = textsTable;
171
+ adapter.relations[`relations_${textsTableName}`] = relations(textsTable, ({ one })=>({
172
+ parent: one(table, {
173
+ fields: [
174
+ textsTable.parent
175
+ ],
176
+ references: [
177
+ table.id
178
+ ],
179
+ relationName: '_texts'
180
+ })
181
+ }));
164
182
  }
165
- numbersTable = adapter.pgSchema.table(numbersTableName, columns, (cols)=>{
166
- const config = {
167
- orderParentIdx: index(`${numbersTableName}_order_parent_idx`).on(cols.order, cols.parent),
168
- parentFk: foreignKey({
169
- name: `${numbersTableName}_parent_fk`,
170
- columns: [
171
- cols.parent
172
- ],
173
- foreignColumns: [
174
- table.id
175
- ]
176
- }).onDelete('cascade')
183
+ if (hasManyNumberField) {
184
+ const numbersTableName = `${rootTableName}_numbers`;
185
+ const columns = {
186
+ id: serial('id').primaryKey(),
187
+ number: numeric('number'),
188
+ order: integer('order').notNull(),
189
+ parent: parentIDColumnMap[idColType]('parent_id').notNull(),
190
+ path: varchar('path').notNull()
177
191
  };
178
- if (hasManyNumberField === 'index') {
179
- config.numberIdx = index(`${numbersTableName}_number_idx`).on(cols.number);
180
- }
181
192
  if (hasLocalizedManyNumberField) {
182
- config.localeParent = index(`${numbersTableName}_locale_parent`).on(cols.locale, cols.parent);
193
+ columns.locale = adapter.enums.enum__locales('locale');
183
194
  }
184
- return config;
185
- });
186
- adapter.tables[numbersTableName] = numbersTable;
187
- const numbersTableRelations = relations(numbersTable, ({ one })=>({
188
- parent: one(table, {
189
- fields: [
190
- numbersTable.parent
191
- ],
192
- references: [
193
- table.id
194
- ]
195
- })
196
- }));
197
- adapter.relations[`relations_${numbersTableName}`] = numbersTableRelations;
198
- }
199
- if (buildRelationships) {
195
+ numbersTable = adapter.pgSchema.table(numbersTableName, columns, (cols)=>{
196
+ const config = {
197
+ orderParentIdx: index(`${numbersTableName}_order_parent_idx`).on(cols.order, cols.parent),
198
+ parentFk: foreignKey({
199
+ name: `${numbersTableName}_parent_fk`,
200
+ columns: [
201
+ cols.parent
202
+ ],
203
+ foreignColumns: [
204
+ table.id
205
+ ]
206
+ }).onDelete('cascade')
207
+ };
208
+ if (hasManyNumberField === 'index') {
209
+ config.numberIdx = index(`${numbersTableName}_number_idx`).on(cols.number);
210
+ }
211
+ if (hasLocalizedManyNumberField) {
212
+ config.localeParent = index(`${numbersTableName}_locale_parent`).on(cols.locale, cols.parent);
213
+ }
214
+ return config;
215
+ });
216
+ adapter.tables[numbersTableName] = numbersTable;
217
+ adapter.relations[`relations_${numbersTableName}`] = relations(numbersTable, ({ one })=>({
218
+ parent: one(table, {
219
+ fields: [
220
+ numbersTable.parent
221
+ ],
222
+ references: [
223
+ table.id
224
+ ],
225
+ relationName: '_numbers'
226
+ })
227
+ }));
228
+ }
200
229
  if (relationships.size) {
201
230
  const relationshipColumns = {
202
231
  id: serial('id').primaryKey(),
@@ -255,7 +284,7 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
255
284
  return result;
256
285
  });
257
286
  adapter.tables[relationshipsTableName] = relationshipsTable;
258
- const relationshipsTableRelations = relations(relationshipsTable, ({ one })=>{
287
+ adapter.relations[`relations_${relationshipsTableName}`] = relations(relationshipsTable, ({ one })=>{
259
288
  const result = {
260
289
  parent: one(table, {
261
290
  fields: [
@@ -280,27 +309,48 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
280
309
  ],
281
310
  references: [
282
311
  adapter.tables[relatedTableName].id
283
- ]
312
+ ],
313
+ relationName: relationTo
284
314
  });
285
315
  });
286
316
  return result;
287
317
  });
288
- adapter.relations[`relations_${relationshipsTableName}`] = relationshipsTableRelations;
289
318
  }
290
319
  }
291
- const tableRelations = relations(table, ({ many })=>{
320
+ adapter.relations[`relations_${tableName}`] = relations(table, ({ many, one })=>{
292
321
  const result = {};
293
- relationsToBuild.forEach((val, key)=>{
294
- result[key] = many(adapter.tables[val]);
322
+ nonLocalizedRelations.forEach(({ type, target }, key)=>{
323
+ if (type === 'one') {
324
+ result[key] = one(adapter.tables[target], {
325
+ fields: [
326
+ table[key]
327
+ ],
328
+ references: [
329
+ adapter.tables[target].id
330
+ ],
331
+ relationName: key
332
+ });
333
+ }
334
+ if (type === 'many') {
335
+ result[key] = many(adapter.tables[target], {
336
+ relationName: key
337
+ });
338
+ }
295
339
  });
296
340
  if (hasLocalizedField) {
297
- result._locales = many(localesTable);
341
+ result._locales = many(localesTable, {
342
+ relationName: '_locales'
343
+ });
298
344
  }
299
345
  if (hasManyTextField) {
300
- result._texts = many(textsTable);
346
+ result._texts = many(textsTable, {
347
+ relationName: '_texts'
348
+ });
301
349
  }
302
350
  if (hasManyNumberField) {
303
- result._numbers = many(numbersTable);
351
+ result._numbers = many(numbersTable, {
352
+ relationName: '_numbers'
353
+ });
304
354
  }
305
355
  if (relationships.size && relationshipsTable) {
306
356
  result._rels = many(relationshipsTable, {
@@ -309,7 +359,6 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
309
359
  }
310
360
  return result;
311
361
  });
312
- adapter.relations[`relations_${tableName}`] = tableRelations;
313
362
  return {
314
363
  hasManyNumberField,
315
364
  hasManyTextField,