@payloadcms/db-postgres 3.0.0-canary.cee5702 → 3.0.0-canary.cf66341

Sign up to get free protection for your applications and to get access to all the features.
Files changed (357) 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 +10 -6
  5. package/dist/connect.js.map +1 -1
  6. package/dist/exports/migration-utils.js.map +1 -1
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +32 -68
  10. package/dist/index.js.map +1 -1
  11. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -1
  12. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +5 -5
  13. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
  14. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +1 -2
  15. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
  16. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +1 -1
  17. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -1
  18. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +1 -1
  19. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -1
  20. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -1
  21. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -1
  22. package/dist/predefinedMigrations/v2-v3/index.d.ts +2 -3
  23. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
  24. package/dist/predefinedMigrations/v2-v3/index.js +7 -7
  25. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
  26. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +5 -4
  27. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
  28. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
  29. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +4 -4
  30. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
  31. package/dist/predefinedMigrations/v2-v3/traverseFields.js +1 -1
  32. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
  33. package/dist/predefinedMigrations/v2-v3/types.js.map +1 -1
  34. package/dist/types.d.ts +42 -80
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/types.js.map +1 -1
  37. package/package.json +20 -17
  38. package/dist/count.d.ts +0 -3
  39. package/dist/count.d.ts.map +0 -1
  40. package/dist/count.js +0 -41
  41. package/dist/count.js.map +0 -1
  42. package/dist/create.d.ts +0 -3
  43. package/dist/create.d.ts.map +0 -1
  44. package/dist/create.js +0 -19
  45. package/dist/create.js.map +0 -1
  46. package/dist/createGlobal.d.ts +0 -5
  47. package/dist/createGlobal.d.ts.map +0 -1
  48. package/dist/createGlobal.js +0 -19
  49. package/dist/createGlobal.js.map +0 -1
  50. package/dist/createGlobalVersion.d.ts +0 -6
  51. package/dist/createGlobalVersion.d.ts.map +0 -1
  52. package/dist/createGlobalVersion.js +0 -33
  53. package/dist/createGlobalVersion.js.map +0 -1
  54. package/dist/createMigration.d.ts +0 -3
  55. package/dist/createMigration.d.ts.map +0 -1
  56. package/dist/createMigration.js +0 -102
  57. package/dist/createMigration.js.map +0 -1
  58. package/dist/createVersion.d.ts +0 -5
  59. package/dist/createVersion.d.ts.map +0 -1
  60. package/dist/createVersion.js +0 -40
  61. package/dist/createVersion.js.map +0 -1
  62. package/dist/deleteMany.d.ts +0 -3
  63. package/dist/deleteMany.d.ts.map +0 -1
  64. package/dist/deleteMany.js +0 -28
  65. package/dist/deleteMany.js.map +0 -1
  66. package/dist/deleteOne.d.ts +0 -3
  67. package/dist/deleteOne.d.ts.map +0 -1
  68. package/dist/deleteOne.js +0 -59
  69. package/dist/deleteOne.js.map +0 -1
  70. package/dist/deleteVersions.d.ts +0 -3
  71. package/dist/deleteVersions.d.ts.map +0 -1
  72. package/dist/deleteVersions.js +0 -31
  73. package/dist/deleteVersions.js.map +0 -1
  74. package/dist/destroy.d.ts +0 -3
  75. package/dist/destroy.d.ts.map +0 -1
  76. package/dist/destroy.js +0 -15
  77. package/dist/destroy.js.map +0 -1
  78. package/dist/find/buildFindManyArgs.d.ts +0 -17
  79. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  80. package/dist/find/buildFindManyArgs.js +0 -65
  81. package/dist/find/buildFindManyArgs.js.map +0 -1
  82. package/dist/find/chainMethods.d.ts +0 -16
  83. package/dist/find/chainMethods.d.ts.map +0 -1
  84. package/dist/find/chainMethods.js +0 -12
  85. package/dist/find/chainMethods.js.map +0 -1
  86. package/dist/find/findMany.d.ts +0 -22
  87. package/dist/find/findMany.d.ts.map +0 -1
  88. package/dist/find/findMany.js +0 -152
  89. package/dist/find/findMany.js.map +0 -1
  90. package/dist/find/traverseFields.d.ts +0 -17
  91. package/dist/find/traverseFields.d.ts.map +0 -1
  92. package/dist/find/traverseFields.js +0 -156
  93. package/dist/find/traverseFields.js.map +0 -1
  94. package/dist/find.d.ts +0 -3
  95. package/dist/find.d.ts.map +0 -1
  96. package/dist/find.js +0 -21
  97. package/dist/find.js.map +0 -1
  98. package/dist/findGlobal.d.ts +0 -3
  99. package/dist/findGlobal.d.ts.map +0 -1
  100. package/dist/findGlobal.js +0 -23
  101. package/dist/findGlobal.js.map +0 -1
  102. package/dist/findGlobalVersions.d.ts +0 -3
  103. package/dist/findGlobalVersions.d.ts.map +0 -1
  104. package/dist/findGlobalVersions.js +0 -24
  105. package/dist/findGlobalVersions.js.map +0 -1
  106. package/dist/findOne.d.ts +0 -5
  107. package/dist/findOne.d.ts.map +0 -1
  108. package/dist/findOne.js +0 -21
  109. package/dist/findOne.js.map +0 -1
  110. package/dist/findVersions.d.ts +0 -3
  111. package/dist/findVersions.d.ts.map +0 -1
  112. package/dist/findVersions.js +0 -24
  113. package/dist/findVersions.js.map +0 -1
  114. package/dist/init.d.ts +0 -3
  115. package/dist/init.d.ts.map +0 -1
  116. package/dist/init.js +0 -91
  117. package/dist/init.js.map +0 -1
  118. package/dist/migrate.d.ts +0 -3
  119. package/dist/migrate.d.ts.map +0 -1
  120. package/dist/migrate.js +0 -99
  121. package/dist/migrate.js.map +0 -1
  122. package/dist/migrateDown.d.ts +0 -3
  123. package/dist/migrateDown.d.ts.map +0 -1
  124. package/dist/migrateDown.js +0 -63
  125. package/dist/migrateDown.js.map +0 -1
  126. package/dist/migrateFresh.d.ts +0 -8
  127. package/dist/migrateFresh.d.ts.map +0 -1
  128. package/dist/migrateFresh.js +0 -72
  129. package/dist/migrateFresh.js.map +0 -1
  130. package/dist/migrateRefresh.d.ts +0 -6
  131. package/dist/migrateRefresh.d.ts.map +0 -1
  132. package/dist/migrateRefresh.js +0 -102
  133. package/dist/migrateRefresh.js.map +0 -1
  134. package/dist/migrateReset.d.ts +0 -6
  135. package/dist/migrateReset.d.ts.map +0 -1
  136. package/dist/migrateReset.js +0 -82
  137. package/dist/migrateReset.js.map +0 -1
  138. package/dist/migrateStatus.d.ts +0 -3
  139. package/dist/migrateStatus.d.ts.map +0 -1
  140. package/dist/migrateStatus.js +0 -44
  141. package/dist/migrateStatus.js.map +0 -1
  142. package/dist/queries/buildAndOrConditions.d.ts +0 -16
  143. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  144. package/dist/queries/buildAndOrConditions.js +0 -28
  145. package/dist/queries/buildAndOrConditions.js.map +0 -1
  146. package/dist/queries/buildQuery.d.ts +0 -30
  147. package/dist/queries/buildQuery.d.ts.map +0 -1
  148. package/dist/queries/buildQuery.js +0 -72
  149. package/dist/queries/buildQuery.js.map +0 -1
  150. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
  151. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  152. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +0 -14
  153. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  154. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
  155. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  156. package/dist/queries/createJSONQuery/formatJSONPathSegment.js +0 -5
  157. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  158. package/dist/queries/createJSONQuery/index.d.ts +0 -10
  159. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  160. package/dist/queries/createJSONQuery/index.js +0 -54
  161. package/dist/queries/createJSONQuery/index.js.map +0 -1
  162. package/dist/queries/getTableColumnFromPath.d.ts +0 -50
  163. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  164. package/dist/queries/getTableColumnFromPath.js +0 -517
  165. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  166. package/dist/queries/operatorMap.d.ts +0 -18
  167. package/dist/queries/operatorMap.d.ts.map +0 -1
  168. package/dist/queries/operatorMap.js +0 -24
  169. package/dist/queries/operatorMap.js.map +0 -1
  170. package/dist/queries/parseParams.d.ts +0 -16
  171. package/dist/queries/parseParams.d.ts.map +0 -1
  172. package/dist/queries/parseParams.js +0 -183
  173. package/dist/queries/parseParams.js.map +0 -1
  174. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  175. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  176. package/dist/queries/sanitizeQueryValue.js +0 -90
  177. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  178. package/dist/queries/selectDistinct.d.ts +0 -22
  179. package/dist/queries/selectDistinct.d.ts.map +0 -1
  180. package/dist/queries/selectDistinct.js +0 -30
  181. package/dist/queries/selectDistinct.js.map +0 -1
  182. package/dist/queryDrafts.d.ts +0 -3
  183. package/dist/queryDrafts.d.ts.map +0 -1
  184. package/dist/queryDrafts.js +0 -41
  185. package/dist/queryDrafts.js.map +0 -1
  186. package/dist/schema/build.d.ts +0 -34
  187. package/dist/schema/build.d.ts.map +0 -1
  188. package/dist/schema/build.js +0 -369
  189. package/dist/schema/build.js.map +0 -1
  190. package/dist/schema/createIndex.d.ts +0 -12
  191. package/dist/schema/createIndex.d.ts.map +0 -1
  192. package/dist/schema/createIndex.js +0 -18
  193. package/dist/schema/createIndex.js.map +0 -1
  194. package/dist/schema/createTableName.d.ts +0 -30
  195. package/dist/schema/createTableName.d.ts.map +0 -1
  196. package/dist/schema/createTableName.js +0 -31
  197. package/dist/schema/createTableName.js.map +0 -1
  198. package/dist/schema/idToUUID.d.ts +0 -3
  199. package/dist/schema/idToUUID.d.ts.map +0 -1
  200. package/dist/schema/idToUUID.js +0 -11
  201. package/dist/schema/idToUUID.js.map +0 -1
  202. package/dist/schema/parentIDColumnMap.d.ts +0 -4
  203. package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
  204. package/dist/schema/parentIDColumnMap.js +0 -9
  205. package/dist/schema/parentIDColumnMap.js.map +0 -1
  206. package/dist/schema/setColumnID.d.ts +0 -11
  207. package/dist/schema/setColumnID.d.ts.map +0 -1
  208. package/dist/schema/setColumnID.js +0 -24
  209. package/dist/schema/setColumnID.js.map +0 -1
  210. package/dist/schema/traverseFields.d.ts +0 -36
  211. package/dist/schema/traverseFields.d.ts.map +0 -1
  212. package/dist/schema/traverseFields.js +0 -614
  213. package/dist/schema/traverseFields.js.map +0 -1
  214. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
  215. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  216. package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
  217. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  218. package/dist/transactions/beginTransaction.d.ts +0 -3
  219. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  220. package/dist/transactions/beginTransaction.js +0 -51
  221. package/dist/transactions/beginTransaction.js.map +0 -1
  222. package/dist/transactions/commitTransaction.d.ts +0 -3
  223. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  224. package/dist/transactions/commitTransaction.js +0 -14
  225. package/dist/transactions/commitTransaction.js.map +0 -1
  226. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  227. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  228. package/dist/transactions/rollbackTransaction.js +0 -13
  229. package/dist/transactions/rollbackTransaction.js.map +0 -1
  230. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  231. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  232. package/dist/transform/read/hasManyNumber.js +0 -10
  233. package/dist/transform/read/hasManyNumber.js.map +0 -1
  234. package/dist/transform/read/hasManyText.d.ts +0 -10
  235. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  236. package/dist/transform/read/hasManyText.js +0 -10
  237. package/dist/transform/read/hasManyText.js.map +0 -1
  238. package/dist/transform/read/index.d.ts +0 -14
  239. package/dist/transform/read/index.d.ts.map +0 -1
  240. package/dist/transform/read/index.js +0 -44
  241. package/dist/transform/read/index.js.map +0 -1
  242. package/dist/transform/read/relationship.d.ts +0 -10
  243. package/dist/transform/read/relationship.d.ts.map +0 -1
  244. package/dist/transform/read/relationship.js +0 -60
  245. package/dist/transform/read/relationship.js.map +0 -1
  246. package/dist/transform/read/traverseFields.d.ts +0 -57
  247. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  248. package/dist/transform/read/traverseFields.js +0 -435
  249. package/dist/transform/read/traverseFields.js.map +0 -1
  250. package/dist/transform/write/array.d.ts +0 -26
  251. package/dist/transform/write/array.d.ts.map +0 -1
  252. package/dist/transform/write/array.js +0 -58
  253. package/dist/transform/write/array.js.map +0 -1
  254. package/dist/transform/write/blocks.d.ts +0 -25
  255. package/dist/transform/write/blocks.d.ts.map +0 -1
  256. package/dist/transform/write/blocks.js +0 -54
  257. package/dist/transform/write/blocks.js.map +0 -1
  258. package/dist/transform/write/index.d.ts +0 -13
  259. package/dist/transform/write/index.d.ts.map +0 -1
  260. package/dist/transform/write/index.js +0 -41
  261. package/dist/transform/write/index.js.map +0 -1
  262. package/dist/transform/write/numbers.d.ts +0 -8
  263. package/dist/transform/write/numbers.d.ts.map +0 -1
  264. package/dist/transform/write/numbers.js +0 -11
  265. package/dist/transform/write/numbers.js.map +0 -1
  266. package/dist/transform/write/relationships.d.ts +0 -10
  267. package/dist/transform/write/relationships.d.ts.map +0 -1
  268. package/dist/transform/write/relationships.js +0 -23
  269. package/dist/transform/write/relationships.js.map +0 -1
  270. package/dist/transform/write/selects.d.ts +0 -8
  271. package/dist/transform/write/selects.d.ts.map +0 -1
  272. package/dist/transform/write/selects.js +0 -20
  273. package/dist/transform/write/selects.js.map +0 -1
  274. package/dist/transform/write/texts.d.ts +0 -8
  275. package/dist/transform/write/texts.d.ts.map +0 -1
  276. package/dist/transform/write/texts.js +0 -11
  277. package/dist/transform/write/texts.js.map +0 -1
  278. package/dist/transform/write/traverseFields.d.ts +0 -50
  279. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  280. package/dist/transform/write/traverseFields.js +0 -445
  281. package/dist/transform/write/traverseFields.js.map +0 -1
  282. package/dist/transform/write/types.d.ts +0 -43
  283. package/dist/transform/write/types.d.ts.map +0 -1
  284. package/dist/transform/write/types.js +0 -3
  285. package/dist/transform/write/types.js.map +0 -1
  286. package/dist/update.d.ts +0 -3
  287. package/dist/update.d.ts.map +0 -1
  288. package/dist/update.js +0 -54
  289. package/dist/update.js.map +0 -1
  290. package/dist/updateGlobal.d.ts +0 -5
  291. package/dist/updateGlobal.d.ts.map +0 -1
  292. package/dist/updateGlobal.js +0 -25
  293. package/dist/updateGlobal.js.map +0 -1
  294. package/dist/updateGlobalVersion.d.ts +0 -5
  295. package/dist/updateGlobalVersion.d.ts.map +0 -1
  296. package/dist/updateGlobalVersion.js +0 -36
  297. package/dist/updateGlobalVersion.js.map +0 -1
  298. package/dist/updateVersion.d.ts +0 -5
  299. package/dist/updateVersion.d.ts.map +0 -1
  300. package/dist/updateVersion.js +0 -36
  301. package/dist/updateVersion.js.map +0 -1
  302. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  303. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  304. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  305. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  306. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  307. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  308. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  309. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  310. package/dist/upsertRow/index.d.ts +0 -4
  311. package/dist/upsertRow/index.d.ts.map +0 -1
  312. package/dist/upsertRow/index.js +0 -279
  313. package/dist/upsertRow/index.js.map +0 -1
  314. package/dist/upsertRow/insertArrays.d.ts +0 -13
  315. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  316. package/dist/upsertRow/insertArrays.js +0 -68
  317. package/dist/upsertRow/insertArrays.js.map +0 -1
  318. package/dist/upsertRow/types.d.ts +0 -32
  319. package/dist/upsertRow/types.d.ts.map +0 -1
  320. package/dist/upsertRow/types.js +0 -3
  321. package/dist/upsertRow/types.js.map +0 -1
  322. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  323. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  324. package/dist/utilities/appendPrefixToKeys.js +0 -6
  325. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  326. package/dist/utilities/createBlocksMap.d.ts +0 -5
  327. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  328. package/dist/utilities/createBlocksMap.js +0 -29
  329. package/dist/utilities/createBlocksMap.js.map +0 -1
  330. package/dist/utilities/createMigrationTable.d.ts +0 -3
  331. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  332. package/dist/utilities/createMigrationTable.js +0 -13
  333. package/dist/utilities/createMigrationTable.js.map +0 -1
  334. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  335. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  336. package/dist/utilities/createRelationshipMap.js +0 -19
  337. package/dist/utilities/createRelationshipMap.js.map +0 -1
  338. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  339. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  340. package/dist/utilities/hasLocalesTable.js +0 -11
  341. package/dist/utilities/hasLocalesTable.js.map +0 -1
  342. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  343. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  344. package/dist/utilities/isArrayOfRows.js +0 -5
  345. package/dist/utilities/isArrayOfRows.js.map +0 -1
  346. package/dist/utilities/migrationTableExists.d.ts +0 -3
  347. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  348. package/dist/utilities/migrationTableExists.js +0 -9
  349. package/dist/utilities/migrationTableExists.js.map +0 -1
  350. package/dist/utilities/parseError.d.ts +0 -5
  351. package/dist/utilities/parseError.d.ts.map +0 -1
  352. package/dist/utilities/parseError.js +0 -17
  353. package/dist/utilities/parseError.js.map +0 -1
  354. package/dist/utilities/pushDevSchema.d.ts +0 -9
  355. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  356. package/dist/utilities/pushDevSchema.js +0 -58
  357. package/dist/utilities/pushDevSchema.js.map +0 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@ npm install @payloadcms/db-postgres
14
14
  ## Usage
15
15
 
16
16
  ```ts
17
- import { buildConfig } from 'payload/config'
17
+ import { buildConfig } from 'payload'
18
18
  import { postgresAdapter } from '@payloadcms/db-postgres'
19
19
 
20
20
  export default buildConfig({
package/dist/connect.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { Connect } from 'payload/database';
1
+ import type { Connect } from 'payload';
2
2
  export declare const connect: Connect;
3
3
  //# sourceMappingURL=connect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AA+C/C,eAAO,MAAM,OAAO,EAAE,OAmDrB,CAAA"}
1
+ {"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,SAAS,CAAA;AA6C/C,eAAO,MAAM,OAAO,EAAE,OAmDrB,CAAA"}
package/dist/connect.js CHANGED
@@ -1,7 +1,6 @@
1
- import { sql } from 'drizzle-orm';
1
+ import { pushDevSchema } from '@payloadcms/drizzle';
2
2
  import { drizzle } from 'drizzle-orm/node-postgres';
3
3
  import pg from 'pg';
4
- import { pushDevSchema } from './utilities/pushDevSchema.js';
5
4
  const connectWithReconnect = async function({ adapter, payload, reconnect = false }) {
6
5
  let result;
7
6
  if (!reconnect) {
@@ -42,6 +41,7 @@ export const connect = async function connect(options = {
42
41
  }) {
43
42
  const { hotReload } = options;
44
43
  this.schema = {
44
+ pgSchema: this.pgSchema,
45
45
  ...this.tables,
46
46
  ...this.relations,
47
47
  ...this.enums
@@ -62,10 +62,9 @@ export const connect = async function connect(options = {
62
62
  if (!hotReload) {
63
63
  if (process.env.PAYLOAD_DROP_DATABASE === 'true') {
64
64
  this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`);
65
- await this.drizzle.execute(sql.raw(`
66
- drop schema if exists ${this.schemaName || 'public'} cascade;
67
- create schema ${this.schemaName || 'public'};
68
- `));
65
+ await this.dropDatabase({
66
+ adapter: this
67
+ });
69
68
  this.payload.logger.info('---- DROPPED TABLES ----');
70
69
  }
71
70
  }
@@ -79,6 +78,11 @@ export const connect = async function connect(options = {
79
78
  await pushDevSchema(this);
80
79
  }
81
80
  if (typeof this.resolveInitializing === 'function') this.resolveInitializing();
81
+ if (process.env.NODE_ENV === 'production' && this.prodMigrations) {
82
+ await this.migrate({
83
+ migrations: this.prodMigrations
84
+ });
85
+ }
82
86
  };
83
87
 
84
88
  //# sourceMappingURL=connect.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { Connect } from 'payload/database'\n\nimport { sql } from 'drizzle-orm'\nimport { drizzle } from 'drizzle-orm/node-postgres'\nimport pg from 'pg'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { pushDevSchema } from './utilities/pushDevSchema.js'\n\nconst connectWithReconnect = async function ({\n adapter,\n payload,\n reconnect = false,\n}: {\n adapter: PostgresAdapter\n payload: Payload\n reconnect?: boolean\n}) {\n let result\n\n if (!reconnect) {\n result = await adapter.pool.connect()\n } else {\n try {\n result = await adapter.pool.connect()\n } catch (err) {\n setTimeout(() => {\n payload.logger.info('Reconnecting to postgres')\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }, 1000)\n }\n }\n if (!result) {\n return\n }\n result.prependListener('error', (err) => {\n try {\n if (err.code === 'ECONNRESET') {\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }\n } catch (err) {\n // swallow error\n }\n })\n}\n\nexport const connect: Connect = async function connect(\n this: PostgresAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n this.schema = {\n ...this.tables,\n ...this.relations,\n ...this.enums,\n }\n\n try {\n if (!this.pool) {\n this.pool = new pg.Pool(this.poolOptions)\n await connectWithReconnect({ adapter: this, payload: this.payload })\n }\n\n const logger = this.logger || false\n this.drizzle = drizzle(this.pool, { logger, schema: this.schema })\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`)\n await this.drizzle.execute(\n sql.raw(`\n drop schema if exists ${this.schemaName || 'public'} cascade;\n create schema ${this.schemaName || 'public'};\n `),\n )\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (err) {\n this.payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err)\n if (typeof this.rejectInitializing === 'function') this.rejectInitializing()\n process.exit(1)\n }\n\n // Only push schema if not in production\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_MIGRATING !== 'true' &&\n this.push !== false\n ) {\n await pushDevSchema(this)\n }\n\n if (typeof this.resolveInitializing === 'function') this.resolveInitializing()\n}\n"],"names":["sql","drizzle","pg","pushDevSchema","connectWithReconnect","adapter","payload","reconnect","result","pool","connect","err","setTimeout","logger","info","prependListener","code","options","hotReload","schema","tables","relations","enums","Pool","poolOptions","process","env","PAYLOAD_DROP_DATABASE","schemaName","execute","raw","error","message","rejectInitializing","exit","NODE_ENV","PAYLOAD_MIGRATING","push","resolveInitializing"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,OAAO,QAAQ,4BAA2B;AACnD,OAAOC,QAAQ,KAAI;AAInB,SAASC,aAAa,QAAQ,+BAA8B;AAE5D,MAAMC,uBAAuB,eAAgB,EAC3CC,OAAO,EACPC,OAAO,EACPC,YAAY,KAAK,EAKlB;IACC,IAAIC;IAEJ,IAAI,CAACD,WAAW;QACdC,SAAS,MAAMH,QAAQI,IAAI,CAACC,OAAO;IACrC,OAAO;QACL,IAAI;YACFF,SAAS,MAAMH,QAAQI,IAAI,CAACC,OAAO;QACrC,EAAE,OAAOC,KAAK;YACZC,WAAW;gBACTN,QAAQO,MAAM,CAACC,IAAI,CAAC;gBACpB,KAAKV,qBAAqB;oBAAEC;oBAASC;oBAASC,WAAW;gBAAK;YAChE,GAAG;QACL;IACF;IACA,IAAI,CAACC,QAAQ;QACX;IACF;IACAA,OAAOO,eAAe,CAAC,SAAS,CAACJ;QAC/B,IAAI;YACF,IAAIA,IAAIK,IAAI,KAAK,cAAc;gBAC7B,KAAKZ,qBAAqB;oBAAEC;oBAASC;oBAASC,WAAW;gBAAK;YAChE;QACF,EAAE,OAAOI,KAAK;QACZ,gBAAgB;QAClB;IACF;AACF;AAEA,OAAO,MAAMD,UAAmB,e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QAC1ER,QAAQS,IAAI,CAAC;IACf;IAEA,wCAAwC;IACxC,IACET,QAAQC,GAAG,CAACS,QAAQ,KAAK,gBACzBV,QAAQC,GAAG,CAACU,iBAAiB,KAAK,UAClC,IAAI,CAACC,IAAI,KAAK,OACd;QACA,MAAMlC,cAAc,IAAI;IAC1B;IAEA,IAAI,OAAO,IAAI,CAACmC,mBAAmB,KAAK,YAAY,IAAI,CAACA,mBAAmB;AAC9E,EAAC"}
1
+ {"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { Connect, Payload } from 'payload'\n\nimport { pushDevSchema } from '@payloadcms/drizzle'\nimport { drizzle } from 'drizzle-orm/node-postgres'\nimport pg from 'pg'\n\nimport type { PostgresAdapter } from './types.js'\n\nconst connectWithReconnect = async function ({\n adapter,\n payload,\n reconnect = false,\n}: {\n adapter: PostgresAdapter\n payload: Payload\n reconnect?: boolean\n}) {\n let result\n\n if (!reconnect) {\n result = await adapter.pool.connect()\n } else {\n try {\n result = await adapter.pool.connect()\n } catch (err) {\n setTimeout(() => {\n payload.logger.info('Reconnecting to postgres')\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }, 1000)\n }\n }\n if (!result) {\n return\n }\n result.prependListener('error', (err) => {\n try {\n if (err.code === 'ECONNRESET') {\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }\n } catch (err) {\n // swallow error\n }\n })\n}\n\nexport const connect: Connect = async function connect(\n this: PostgresAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n this.schema = {\n pgSchema: this.pgSchema,\n ...this.tables,\n ...this.relations,\n ...this.enums,\n }\n\n try {\n if (!this.pool) {\n this.pool = new pg.Pool(this.poolOptions)\n await connectWithReconnect({ adapter: this, payload: this.payload })\n }\n\n const logger = this.logger || false\n this.drizzle = drizzle(this.pool, { logger, schema: this.schema })\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`)\n await this.dropDatabase({ adapter: this })\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (err) {\n this.payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err)\n if (typeof this.rejectInitializing === 'function') this.rejectInitializing()\n process.exit(1)\n }\n\n // Only push schema if not in production\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_MIGRATING !== 'true' &&\n this.push !== false\n ) {\n await pushDevSchema(this as unknown as DrizzleAdapter)\n }\n\n if (typeof this.resolveInitializing === 'function') this.resolveInitializing()\n\n if (process.env.NODE_ENV === 'production' && this.prodMigrations) {\n await this.migrate({ migrations: this.prodMigrations })\n }\n}\n"],"names":["pushDevSchema","drizzle","pg","connectWithReconnect","adapter","payload","reconnect","result","pool","connect","err","setTimeout","logger","info","prependListener","code","options","hotReload","schema","pgSchema","tables","relations","enums","Pool","poolOptions","process","env","PAYLOAD_DROP_DATABASE","schemaName","dropDatabase","error","message","rejectInitializing","exit","NODE_ENV","PAYLOAD_MIGRATING","push","resolveInitializing","prodMigrations","migrate","migrations"],"mappings":"AAGA,SAASA,aAAa,QAAQ,sBAAqB;AACnD,SAASC,OAAO,QAAQ,4BAA2B;AACnD,OAAOC,QAAQ,KAAI;AAInB,MAAMC,uBAAuB,eAAgB,EAC3CC,OAAO,EACPC,OAAO,EACPC,YAAY,KAAK,EAKlB;IACC,IAAIC;IAEJ,IAAI,CAACD,WAAW;QACdC,SAAS,MAAMH,QAAQI,IAAI,CAACC,OAAO;IACrC,OAAO;QACL,IAAI;YACFF,SAAS,MAAMH,QAAQI,IAAI,CAACC,OAAO;QACrC,EAAE,OAAOC,KAAK;YACZC,WAAW;gBACTN,QAAQO,MAAM,CAACC,IAAI,CAAC;gBACpB,KAAKV,qBAAqB;oBAAEC;oBAASC;oBAASC,WAAW;gBAAK;YAChE,GAAG;QACL;IACF;IACA,IAAI,CAACC,QAAQ;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O,CAACO,MAAM,CAACkB,KAAK,CAAC,CAAC,4CAA4C,EAAEpB,IAAIqB,OAAO,CAAC,CAAC,EAAErB;QACxF,IAAI,OAAO,IAAI,CAACsB,kBAAkB,KAAK,YAAY,IAAI,CAACA,kBAAkB;QAC1EP,QAAQQ,IAAI,CAAC;IACf;IAEA,wCAAwC;IACxC,IACER,QAAQC,GAAG,CAACQ,QAAQ,KAAK,gBACzBT,QAAQC,GAAG,CAACS,iBAAiB,KAAK,UAClC,IAAI,CAACC,IAAI,KAAK,OACd;QACA,MAAMpC,cAAc,IAAI;IAC1B;IAEA,IAAI,OAAO,IAAI,CAACqC,mBAAmB,KAAK,YAAY,IAAI,CAACA,mBAAmB;IAE5E,IAAIZ,QAAQC,GAAG,CAACQ,QAAQ,KAAK,gBAAgB,IAAI,CAACI,cAAc,EAAE;QAChE,MAAM,IAAI,CAACC,OAAO,CAAC;YAAEC,YAAY,IAAI,CAACF,cAAc;QAAC;IACvD;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/migration-utils.ts"],"sourcesContent":["export { migratePostgresV2toV3 } from '../predefinedMigrations/v2-v3/index.js'\n"],"names":["migratePostgresV2toV3"],"rangeMappings":"","mappings":"AAAA,SAASA,qBAAqB,QAAQ,yCAAwC"}
1
+ {"version":3,"sources":["../../src/exports/migration-utils.ts"],"sourcesContent":["export { migratePostgresV2toV3 } from '../predefinedMigrations/v2-v3/index.js'\n"],"names":["migratePostgresV2toV3"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,yCAAwC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { DatabaseAdapterObj } from 'payload/database';
1
+ import type { DatabaseAdapterObj } from 'payload';
2
2
  import type { Args, PostgresAdapter } from './types.js';
3
- export type { MigrateDownArgs, MigrateUpArgs } from './types.js';
4
- export { sql } from 'drizzle-orm';
5
3
  export declare function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter>;
4
+ export type { MigrateDownArgs, MigrateUpArgs } from '@payloadcms/drizzle/postgres';
5
+ export { sql } from 'drizzle-orm';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAM1D,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAkCvD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAgF/E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAW,MAAM,SAAS,CAAA;AAmD1D,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIvD,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAuG/E;AAED,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAClF,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -1,38 +1,8 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { createDatabaseAdapter } from 'payload/database';
1
+ import { beginTransaction, commitTransaction, count, create, createGlobal, createGlobalVersion, createVersion, deleteMany, deleteOne, deleteVersions, destroy, find, findGlobal, findGlobalVersions, findMigrationDir, findOne, findVersions, migrate, migrateDown, migrateFresh, migrateRefresh, migrateReset, migrateStatus, operatorMap, queryDrafts, rollbackTransaction, updateGlobal, updateGlobalVersion, updateOne, updateVersion } from '@payloadcms/drizzle';
2
+ import { convertPathToJSONTraversal, countDistinct, createJSONQuery, createMigration, defaultDrizzleSnapshot, deleteWhere, dropDatabase, execute, getMigrationTemplate, init, insert, requireDrizzleKit } from '@payloadcms/drizzle/postgres';
3
+ import { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core';
4
+ import { createDatabaseAdapter } from 'payload';
4
5
  import { connect } from './connect.js';
5
- import { count } from './count.js';
6
- import { create } from './create.js';
7
- import { createGlobal } from './createGlobal.js';
8
- import { createGlobalVersion } from './createGlobalVersion.js';
9
- import { createMigration } from './createMigration.js';
10
- import { createVersion } from './createVersion.js';
11
- import { deleteMany } from './deleteMany.js';
12
- import { deleteOne } from './deleteOne.js';
13
- import { deleteVersions } from './deleteVersions.js';
14
- import { destroy } from './destroy.js';
15
- import { find } from './find.js';
16
- import { findGlobal } from './findGlobal.js';
17
- import { findGlobalVersions } from './findGlobalVersions.js';
18
- import { findOne } from './findOne.js';
19
- import { findVersions } from './findVersions.js';
20
- import { init } from './init.js';
21
- import { migrate } from './migrate.js';
22
- import { migrateDown } from './migrateDown.js';
23
- import { migrateFresh } from './migrateFresh.js';
24
- import { migrateRefresh } from './migrateRefresh.js';
25
- import { migrateReset } from './migrateReset.js';
26
- import { migrateStatus } from './migrateStatus.js';
27
- import { queryDrafts } from './queryDrafts.js';
28
- import { beginTransaction } from './transactions/beginTransaction.js';
29
- import { commitTransaction } from './transactions/commitTransaction.js';
30
- import { rollbackTransaction } from './transactions/rollbackTransaction.js';
31
- import { updateOne } from './update.js';
32
- import { updateGlobal } from './updateGlobal.js';
33
- import { updateGlobalVersion } from './updateGlobalVersion.js';
34
- import { updateVersion } from './updateVersion.js';
35
- export { sql } from 'drizzle-orm';
36
6
  export function postgresAdapter(args) {
37
7
  const postgresIDType = args.idType || 'serial';
38
8
  const payloadIDType = postgresIDType === 'serial' ? 'number' : 'text';
@@ -40,22 +10,38 @@ export function postgresAdapter(args) {
40
10
  const migrationDir = findMigrationDir(args.migrationDir);
41
11
  let resolveInitializing;
42
12
  let rejectInitializing;
13
+ let adapterSchema;
43
14
  const initializing = new Promise((res, rej)=>{
44
15
  resolveInitializing = res;
45
16
  rejectInitializing = rej;
46
17
  });
18
+ if (args.schemaName) {
19
+ adapterSchema = pgSchema(args.schemaName);
20
+ } else {
21
+ adapterSchema = {
22
+ enum: pgEnum,
23
+ table: pgTable
24
+ };
25
+ }
47
26
  return createDatabaseAdapter({
48
27
  name: 'postgres',
28
+ defaultDrizzleSnapshot,
49
29
  drizzle: undefined,
50
30
  enums: {},
31
+ features: {
32
+ json: true
33
+ },
51
34
  fieldConstraints: {},
35
+ getMigrationTemplate,
52
36
  idType: postgresIDType,
53
37
  initializing,
54
38
  localesSuffix: args.localesSuffix || '_locales',
55
39
  logger: args.logger,
56
- pgSchema: undefined,
40
+ operators: operatorMap,
41
+ pgSchema: adapterSchema,
57
42
  pool: undefined,
58
43
  poolOptions: args.pool,
44
+ prodMigrations: args.prodMigrations,
59
45
  push: args.push,
60
46
  relations: {},
61
47
  relationshipsSuffix: args.relationshipsSuffix || '_rels',
@@ -64,28 +50,36 @@ export function postgresAdapter(args) {
64
50
  sessions: {},
65
51
  tableNameMap: new Map(),
66
52
  tables: {},
53
+ transactionOptions: args.transactionOptions || undefined,
67
54
  versionsSuffix: args.versionsSuffix || '_v',
68
55
  // DatabaseAdapter
69
- beginTransaction,
56
+ beginTransaction: args.transactionOptions === false ? undefined : beginTransaction,
70
57
  commitTransaction,
71
58
  connect,
59
+ convertPathToJSONTraversal,
72
60
  count,
61
+ countDistinct,
73
62
  create,
74
63
  createGlobal,
75
64
  createGlobalVersion,
65
+ createJSONQuery,
76
66
  createMigration,
77
67
  createVersion,
78
68
  defaultIDType: payloadIDType,
79
69
  deleteMany,
80
70
  deleteOne,
81
71
  deleteVersions,
72
+ deleteWhere,
82
73
  destroy,
74
+ dropDatabase,
75
+ execute,
83
76
  find,
84
77
  findGlobal,
85
78
  findGlobalVersions,
86
79
  findOne,
87
80
  findVersions,
88
81
  init,
82
+ insert,
89
83
  migrate,
90
84
  migrateDown,
91
85
  migrateFresh,
@@ -96,6 +90,7 @@ export function postgresAdapter(args) {
96
90
  payload,
97
91
  queryDrafts,
98
92
  rejectInitializing,
93
+ requireDrizzleKit,
99
94
  resolveInitializing,
100
95
  rollbackTransaction,
101
96
  updateGlobal,
@@ -109,37 +104,6 @@ export function postgresAdapter(args) {
109
104
  init: adapter
110
105
  };
111
106
  }
112
- /**
113
- * Attempt to find migrations directory.
114
- *
115
- * Checks for the following directories in order:
116
- * - `migrationDir` argument from Payload config
117
- * - `src/migrations`
118
- * - `dist/migrations`
119
- * - `migrations`
120
- *
121
- * Defaults to `src/migrations`
122
- *
123
- * @param migrationDir
124
- * @returns
125
- */ function findMigrationDir(migrationDir) {
126
- const cwd = process.cwd();
127
- const srcDir = path.resolve(cwd, 'src/migrations');
128
- const distDir = path.resolve(cwd, 'dist/migrations');
129
- const relativeMigrations = path.resolve(cwd, 'migrations');
130
- // Use arg if provided
131
- if (migrationDir) return migrationDir;
132
- // Check other common locations
133
- if (fs.existsSync(srcDir)) {
134
- return srcDir;
135
- }
136
- if (fs.existsSync(distDir)) {
137
- return distDir;
138
- }
139
- if (fs.existsSync(relativeMigrations)) {
140
- return relativeMigrations;
141
- }
142
- return srcDir;
143
- }
107
+ export { sql } from 'drizzle-orm';
144
108
 
145
109
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { DatabaseAdapterObj } from 'payload/database'\n\nimport fs from 'fs'\nimport path from 'path'\nimport { createDatabaseAdapter } from 'payload/database'\n\nimport type { Args, PostgresAdapter } from './types.js'\n\nimport { connect } from './connect.js'\nimport { count } from './count.js'\nimport { create } from './create.js'\nimport { createGlobal } from './createGlobal.js'\nimport { createGlobalVersion } from './createGlobalVersion.js'\nimport { createMigration } from './createMigration.js'\nimport { createVersion } from './createVersion.js'\nimport { deleteMany } from './deleteMany.js'\nimport { deleteOne } from './deleteOne.js'\nimport { deleteVersions } from './deleteVersions.js'\nimport { destroy } from './destroy.js'\nimport { find } from './find.js'\nimport { findGlobal } from './findGlobal.js'\nimport { findGlobalVersions } from './findGlobalVersions.js'\nimport { findOne } from './findOne.js'\nimport { findVersions } from './findVersions.js'\nimport { init } from './init.js'\nimport { migrate } from './migrate.js'\nimport { migrateDown } from './migrateDown.js'\nimport { migrateFresh } from './migrateFresh.js'\nimport { migrateRefresh } from './migrateRefresh.js'\nimport { migrateReset } from './migrateReset.js'\nimport { migrateStatus } from './migrateStatus.js'\nimport { queryDrafts } from './queryDrafts.js'\nimport { beginTransaction } from './transactions/beginTransaction.js'\nimport { commitTransaction } from './transactions/commitTransaction.js'\nimport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nimport { updateOne } from './update.js'\nimport { updateGlobal } from './updateGlobal.js'\nimport { updateGlobalVersion } from './updateGlobalVersion.js'\nimport { updateVersion } from './updateVersion.js'\n\nexport type { MigrateDownArgs, MigrateUpArgs } from './types.js'\n\nexport { sql } from 'drizzle-orm'\n\nexport function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {\n const postgresIDType = args.idType || 'serial'\n const payloadIDType = postgresIDType === 'serial' ? 'number' : 'text'\n\n function adapter({ payload }: { payload: Payload }) {\n const migrationDir = findMigrationDir(args.migrationDir)\n let resolveInitializing\n let rejectInitializing\n\n const initializing = new Promise<void>((res, rej) => {\n resolveInitializing = res\n rejectInitializing = rej\n })\n\n return createDatabaseAdapter<PostgresAdapter>({\n name: 'postgres',\n drizzle: undefined,\n enums: {},\n fieldConstraints: {},\n idType: postgresIDType,\n initializing,\n localesSuffix: args.localesSuffix || '_locales',\n logger: args.logger,\n pgSchema: undefined,\n pool: undefined,\n poolOptions: args.pool,\n push: args.push,\n relations: {},\n relationshipsSuffix: args.relationshipsSuffix || '_rels',\n schema: {},\n schemaName: args.schemaName,\n sessions: {},\n tableNameMap: new Map<string, string>(),\n tables: {},\n versionsSuffix: args.versionsSuffix || '_v',\n\n // DatabaseAdapter\n beginTransaction,\n commitTransaction,\n connect,\n count,\n create,\n createGlobal,\n createGlobalVersion,\n createMigration,\n createVersion,\n defaultIDType: payloadIDType,\n deleteMany,\n deleteOne,\n deleteVersions,\n destroy,\n find,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n init,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n migrationDir,\n payload,\n queryDrafts,\n rejectInitializing,\n resolveInitializing,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n })\n }\n\n return {\n defaultIDType: payloadIDType,\n init: adapter,\n }\n}\n\n/**\n * Attempt to find migrations directory.\n *\n * Checks for the following directories in order:\n * - `migrationDir` argument from Payload config\n * - `src/migrations`\n * - `dist/migrations`\n * - `migrations`\n *\n * Defaults to `src/migrations`\n *\n * @param migrationDir\n * @returns\n */\nfunction findMigrationDir(migrationDir?: string): string {\n const cwd = process.cwd()\n const srcDir = path.resolve(cwd, 'src/migrations')\n const distDir = path.resolve(cwd, 'dist/migrations')\n const relativeMigrations = path.resolve(cwd, 'migrations')\n\n // Use arg if provided\n if (migrationDir) return migrationDir\n\n // Check other common locations\n if (fs.existsSync(srcDir)) {\n return srcDir\n }\n\n if (fs.existsSync(distDir)) {\n return distDir\n }\n\n if (fs.existsSync(relativeMigrations)) {\n return relativeMigrations\n }\n\n return srcDir\n}\n"],"names":["fs","path","createDatabaseAdapter","connect","count","create","createGlobal","createGlobalVersion","createMigration","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findGlobal","findGlobalVersions","findOne","findVersions","init","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","queryDrafts","beginTransaction","commitTransaction","rollbackTransaction","updateOne","updateGlobal","updateGlobalVersion","updateVersion","sql","postgresAdapter","args","postgresIDType","idType","payloadIDType","adapter","payload","migrationDir","findMigrationDir","resolveInitializing","rejectInitializing","initializing","Promise","res","rej","name","drizzle","undefined","enums","fieldConstraints","localesSuffix","logger","pgSchema","pool","poolOptions","push","relations","relationshipsSuffix","schema","schemaName","sessions","tableNameMap","Map","tables","versionsSuffix","defaultIDType","cwd","process","srcDir","resolve","distDir","relativeMigrations","existsSync"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,qBAAqB,QAAQ,mBAAkB;AAIxD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,KAAK,QAAQ,aAAY;AAClC,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,aAAa,QAAQ,qBAAoB;A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;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAiB;YACAD;YACAf;YACAmB;YACAD;YACAf;YACAE;YACAC;YACAF;YACAG;QACF;IACF;IAEA,OAAO;QACLqC,eAAe/B;QACfpB,MAAMqB;IACR;AACF;AAEA;;;;;;;;;;;;;CAaC,GACD,SAASG,iBAAiBD,YAAqB;IAC7C,MAAM6B,MAAMC,QAAQD,GAAG;IACvB,MAAME,SAASxE,KAAKyE,OAAO,CAACH,KAAK;IACjC,MAAMI,UAAU1E,KAAKyE,OAAO,CAACH,KAAK;IAClC,MAAMK,qBAAqB3E,KAAKyE,OAAO,CAACH,KAAK;IAE7C,sBAAsB;IACtB,IAAI7B,cAAc,OAAOA;IAEzB,+BAA+B;IAC/B,IAAI1C,GAAG6E,UAAU,CAACJ,SAAS;QACzB,OAAOA;IACT;IAEA,IAAIzE,GAAG6E,UAAU,CAACF,UAAU;QAC1B,OAAOA;IACT;IAEA,IAAI3E,GAAG6E,UAAU,CAACD,qBAAqB;QACrC,OAAOA;IACT;IAEA,OAAOH;AACT"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { DatabaseAdapterObj, Payload } from 'payload'\n\nimport {\n beginTransaction,\n commitTransaction,\n count,\n create,\n createGlobal,\n createGlobalVersion,\n createVersion,\n deleteMany,\n deleteOne,\n deleteVersions,\n destroy,\n find,\n findGlobal,\n findGlobalVersions,\n findMigrationDir,\n findOne,\n findVersions,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n operatorMap,\n queryDrafts,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n} from '@payloadcms/drizzle'\nimport {\n convertPathToJSONTraversal,\n countDistinct,\n createJSONQuery,\n createMigration,\n defaultDrizzleSnapshot,\n deleteWhere,\n dropDatabase,\n execute,\n getMigrationTemplate,\n init,\n insert,\n requireDrizzleKit,\n} from '@payloadcms/drizzle/postgres'\nimport { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core'\nimport { createDatabaseAdapter } from 'payload'\n\nimport type { Args, PostgresAdapter } from './types.js'\n\nimport { connect } from './connect.js'\n\nexport function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {\n const postgresIDType = args.idType || 'serial'\n const payloadIDType = postgresIDType === 'serial' ? 'number' : 'text'\n\n function adapter({ payload }: { payload: Payload }) {\n const migrationDir = findMigrationDir(args.migrationDir)\n let resolveInitializing\n let rejectInitializing\n let adapterSchema: PostgresAdapter['pgSchema']\n\n const initializing = new Promise<void>((res, rej) => {\n resolveInitializing = res\n rejectInitializing = rej\n })\n\n if (args.schemaName) {\n adapterSchema = pgSchema(args.schemaName)\n } else {\n adapterSchema = { enum: pgEnum, table: pgTable }\n }\n\n return createDatabaseAdapter<PostgresAdapter>({\n name: 'postgres',\n defaultDrizzleSnapshot,\n drizzle: undefined,\n enums: {},\n features: {\n json: true,\n },\n fieldConstraints: {},\n getMigrationTemplate,\n idType: postgresIDType,\n initializing,\n localesSuffix: args.localesSuffix || '_locales',\n logger: args.logger,\n operators: operatorMap,\n pgSchema: adapterSchema,\n pool: undefined,\n poolOptions: args.pool,\n prodMigrations: args.prodMigrations,\n push: args.push,\n relations: {},\n relationshipsSuffix: args.relationshipsSuffix || '_rels',\n schema: {},\n schemaName: args.schemaName,\n sessions: {},\n tableNameMap: new Map<string, string>(),\n tables: {},\n transactionOptions: args.transactionOptions || undefined,\n versionsSuffix: args.versionsSuffix || '_v',\n\n // DatabaseAdapter\n beginTransaction: args.transactionOptions === false ? undefined : beginTransaction,\n commitTransaction,\n connect,\n convertPathToJSONTraversal,\n count,\n countDistinct,\n create,\n createGlobal,\n createGlobalVersion,\n createJSONQuery,\n createMigration,\n createVersion,\n defaultIDType: payloadIDType,\n deleteMany,\n deleteOne,\n deleteVersions,\n deleteWhere,\n destroy,\n dropDatabase,\n execute,\n find,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n init,\n insert,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n migrationDir,\n payload,\n queryDrafts,\n rejectInitializing,\n requireDrizzleKit,\n resolveInitializing,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n })\n }\n\n return {\n defaultIDType: payloadIDType,\n init: adapter,\n }\n}\n\nexport type { MigrateDownArgs, MigrateUpArgs } from '@payloadcms/drizzle/postgres'\nexport { sql } from 'drizzle-orm'\n"],"names":["beginTransaction","commitTransaction","count","create","createGlobal","createGlobalVersion","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findGlobal","findGlobalVersions","findMigrationDir","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","operatorMap","queryDrafts","rollbackTransaction","updateGlobal","updateGlobalVersion","updateOne","updateVersion","convertPathToJSONTraversal","countDistinct","createJSONQuery","createMigration","defaultDrizzleSnapshot","deleteWhere","dropDatabase","execute","getMigrationTemplate","init","insert","requireDrizzleKit","pgEnum","pgSchema","pgTable","createDatabaseAdapter","connect","postgresAdapter","args","postgresIDType","idType","payloadIDType","adapter","payload","migrationDir","resolveInitializing","rejectInitializing","adapterSchema","initializing","Promise","res","rej","schemaName","enum","table","name","drizzle","undefined","enums","features","json","fieldConstraints","localesSuffix","logger","operators","pool","poolOptions","prodMigrations","push","relations","relationshipsSuffix","schema","sessions","tableNameMap","Map","tables","transactionOptions","versionsSuffix","defaultIDType","sql"],"mappings":"AAEA,SACEA,gBAAgB,EAChBC,iBAAiB,EACjBC,KAAK,EACLC,MAAM,EACNC,YAAY,EACZC,mBAAmB,EACnBC,aAAa,EACbC,UAAU,EACVC,SAAS,EACTC,cAAc,EACdC,OAAO,EACPC,IAAI,EACJC,UAAU,EACVC,kBAAkB,EAClBC,gBAAgB,EAChBC,OAAO,EACPC,YAAY,EACZC,OAAO,EACPC,WAAW,EACXC,YAAY,EACZC,cAAc,EACdC,YAAY,EACZC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AAM9B,KAAK8B,IAAI;YACfC,WAAW,CAAC;YACZC,qBAAqBhC,KAAKgC,mBAAmB,IAAI;YACjDC,QAAQ,CAAC;YACTnB,YAAYd,KAAKc,UAAU;YAC3BoB,UAAU,CAAC;YACXC,cAAc,IAAIC;YAClBC,QAAQ,CAAC;YACTC,oBAAoBtC,KAAKsC,kBAAkB,IAAInB;YAC/CoB,gBAAgBvC,KAAKuC,cAAc,IAAI;YAEvC,kBAAkB;YAClBvF,kBAAkBgD,KAAKsC,kBAAkB,KAAK,QAAQnB,YAAYnE;YAClEC;YACA6C;YACAhB;YACA5B;YACA6B;YACA5B;YACAC;YACAC;YACA2B;YACAC;YACA3B;YACAkF,eAAerC;YACf5C;YACAC;YACAC;YACA0B;YACAzB;YACA0B;YACAC;YACA1B;YACAC;YACAC;YACAE;YACAC;YACAuB;YACAC;YACAvB;YACAC;YACAC;YACAC;YACAC;YACAC;YACAgC;YACAD;YACA7B;YACAgC;YACAf;YACAc;YACA9B;YACAC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAO;QACL2D,eAAerC;QACfZ,MAAMa;IACR;AACF;AAGA,SAASqC,GAAG,QAAQ,cAAa"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/predefinedMigrations/relationships-v2-v3.ts"],"sourcesContent":["const imports = `import { migratePostgresV2toV3 } from '@payloadcms/db-postgres/migration-utils'`\nconst upSQL = ` await migratePostgresV2toV3({\n // enables logging of changes that will be made to the database\n debug: false,\n payload,\n req,\n })\n`\n\nexport { imports, upSQL }\n"],"names":["imports","upSQL"],"rangeMappings":";;;;;;;;","mappings":"AAAA,MAAMA,UAAU,CAAC,+EAA+E,CAAC;AACjG,MAAMC,QAAQ,CAAC;;;;;;AAMf,CAAC;AAED,SAASD,OAAO,EAAEC,KAAK,GAAE"}
1
+ {"version":3,"sources":["../../src/predefinedMigrations/relationships-v2-v3.ts"],"sourcesContent":["const imports = `import { migratePostgresV2toV3 } from '@payloadcms/db-postgres/migration-utils'`\nconst upSQL = ` await migratePostgresV2toV3({\n // enables logging of changes that will be made to the database\n debug: false,\n payload,\n req,\n })\n`\n\nexport { imports, upSQL }\n"],"names":["imports","upSQL"],"mappings":"AAAA,MAAMA,UAAU,CAAC,+EAA+E,CAAC;AACjG,MAAMC,QAAQ,CAAC;;;;;;AAMf,CAAC;AAED,SAASD,OAAO,EAAEC,KAAK,GAAE"}
@@ -1,18 +1,18 @@
1
- import type { Payload } from 'payload';
2
- import type { Field, PayloadRequestWithData } from 'payload/types';
3
- import type { DrizzleTransaction, PostgresAdapter } from '../../../types.js';
1
+ import type { TransactionPg } from '@payloadcms/drizzle/types';
2
+ import type { Field, Payload, PayloadRequest } from 'payload';
3
+ import type { PostgresAdapter } from '../../../types.js';
4
4
  import type { DocsToResave } from '../types.js';
5
5
  type Args = {
6
6
  adapter: PostgresAdapter;
7
7
  collectionSlug?: string;
8
- db: DrizzleTransaction;
8
+ db: TransactionPg;
9
9
  debug: boolean;
10
10
  docsToResave: DocsToResave;
11
11
  fields: Field[];
12
12
  globalSlug?: string;
13
13
  isVersions: boolean;
14
14
  payload: Payload;
15
- req: PayloadRequestWithData;
15
+ req: PayloadRequest;
16
16
  tableName: string;
17
17
  };
18
18
  export declare const fetchAndResave: ({ adapter, collectionSlug, db, debug, docsToResave, fields, globalSlug, isVersions, payload, req, tableName, }: Args) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/predefinedMigrations/v2-v3/fetchAndResave/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAElE,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK/C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,EAAE,EAAE,kBAAkB,CAAA;IACtB,KAAK,EAAE,OAAO,CAAA;IACd,YAAY,EAAE,YAAY,CAAA;IAC1B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,sBAAsB,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,cAAc,mHAYxB,IAAI,kBAyMN,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/predefinedMigrations/v2-v3/fetchAndResave/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,EAAE,EAAE,aAAa,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,YAAY,EAAE,YAAY,CAAA;IAC1B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,cAAc,mHAYxB,IAAI,kBAwMN,CAAA"}
@@ -1,4 +1,4 @@
1
- import { upsertRow } from '../../../upsertRow/index.js';
1
+ import { upsertRow } from '@payloadcms/drizzle';
2
2
  import { traverseFields } from './traverseFields.js';
3
3
  export const fetchAndResave = async ({ adapter, collectionSlug, db, debug, docsToResave, fields, globalSlug, isVersions, payload, req, tableName })=>{
4
4
  for (const [id, rows] of Object.entries(docsToResave)){
@@ -144,7 +144,6 @@ export const fetchAndResave = async ({ adapter, collectionSlug, db, debug, docsT
144
144
  });
145
145
  try {
146
146
  await upsertRow({
147
- id: doc.id,
148
147
  adapter,
149
148
  data: doc,
150
149
  db,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/predefinedMigrations/v2-v3/fetchAndResave/index.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport type { Field, PayloadRequestWithData } from 'payload/types'\n\nimport type { DrizzleTransaction, PostgresAdapter } from '../../../types.js'\nimport type { DocsToResave } from '../types.js'\n\nimport { upsertRow } from '../../../upsertRow/index.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n db: DrizzleTransaction\n debug: boolean\n docsToResave: DocsToResave\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n payload: Payload\n req: PayloadRequestWithData\n tableName: string\n}\n\nexport const fetchAndResave = async ({\n adapter,\n collectionSlug,\n db,\n debug,\n docsToResave,\n fields,\n globalSlug,\n isVersions,\n payload,\n req,\n tableName,\n}: Args) => {\n for (const [id, rows] of Object.entries(docsToResave)) {\n if (collectionSlug) {\n const collectionConfig = payload.collections[collectionSlug].config\n\n if (collectionConfig) {\n if (isVersions) {\n const doc = await payload.findVersionByID({\n id,\n collection: collectionSlug,\n depth: 0,\n fallbackLocale: null,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n if (debug) {\n payload.logger.info(\n `The collection \"${collectionConfig.slug}\" version with ID ${id} will be migrated`,\n )\n }\n\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n id: doc.id,\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(\n `\"${collectionConfig.slug}\" version with ID ${doc.id} FAILED TO MIGRATE`,\n )\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(\n `\"${collectionConfig.slug}\" version with ID ${doc.id} migrated successfully!`,\n )\n }\n } else {\n const doc = await payload.findByID({\n id,\n collection: collectionSlug,\n depth: 0,\n fallbackLocale: null,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n if (debug) {\n payload.logger.info(\n `The collection \"${collectionConfig.slug}\" with ID ${doc.id} will be migrated`,\n )\n }\n\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n id: doc.id,\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(\n `The collection \"${collectionConfig.slug}\" with ID ${doc.id} has FAILED TO MIGRATE`,\n )\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(\n `The collection \"${collectionConfig.slug}\" with ID ${doc.id} has migrated successfully!`,\n )\n }\n }\n }\n }\n\n if (globalSlug) {\n const globalConfig = payload.config.globals?.find((global) => global.slug === globalSlug)\n\n if (globalConfig) {\n if (isVersions) {\n const { docs } = await payload.findGlobalVersions({\n slug: globalSlug,\n depth: 0,\n fallbackLocale: null,\n limit: 0,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n if (debug) {\n payload.logger.info(`${docs.length} global \"${globalSlug}\" versions will be migrated`)\n }\n\n for (const doc of docs) {\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n id: doc.id,\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(`\"${globalSlug}\" version with ID ${doc.id} FAILED TO MIGRATE`)\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(\n `\"${globalSlug}\" version with ID ${doc.id} migrated successfully!`,\n )\n }\n }\n } else {\n const doc = await payload.findGlobal({\n slug: globalSlug,\n depth: 0,\n fallbackLocale: null,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n id: doc.id,\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(`The global \"${globalSlug}\" has FAILED TO MIGRATE`)\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(`The global \"${globalSlug}\" has migrated successfully!`)\n }\n }\n }\n }\n }\n}\n"],"names":["upsertRow","traverseFields","fetchAndResave","adapter","collectionSlug","db","debug","docsToResave","fields","globalSlug","isVersions","payload","req","tableName","id","rows","Object","entries","collectionConfig","collections","config","doc","findVersionByID","collection","depth","fallbackLocale","locale","showHiddenFields","logger","info","slug","path","data","ignoreResult","operation","err","error","findByID","globalConfig","globals","find","global","docs","findGlobalVersions","limit","length","findGlobal"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAMA,SAASA,SAAS,QAAQ,8BAA6B;AACvD,SAASC,cAAc,QAAQ,sBAAqB;AAgBpD,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,OAAO,EACPC,cAAc,EACdC,EAAE,EACFC,KAAK,EACLC,YAAY,EACZC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,OAAO,EACPC,GAAG,EACHC,SAAS,EACJ;IACL,KAAK,MAAM,CAACC,IAAIC,KAAK,IAAIC,OAAOC,OAAO,CAACV,cAAe;QACrD,IAAIH,gBAAgB;YAClB,MAAMc,mBAAmBP,QAAQQ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CACAyB,cAAc;gCACdC,WAAW;gCACXtB;gCACAC;4BACF;wBACF,EAAE,OAAOsB,KAAK;4BACZxB,QAAQiB,MAAM,CAACQ,KAAK,CAAC,CAAC,CAAC,EAAE3B,WAAW,kBAAkB,EAAEY,IAAIP,EAAE,CAAC,kBAAkB,CAAC;4BAElF,MAAMqB;wBACR;wBAEA,IAAI7B,OAAO;4BACTK,QAAQiB,MAAM,CAACC,IAAI,CACjB,CAAC,CAAC,EAAEpB,WAAW,kBAAkB,EAAEY,IAAIP,EAAE,CAAC,uBAAuB,CAAC;wBAEtE;oBACF;gBACF,OAAO;oBACL,MAAMO,MAAM,MAAMV,QAAQmC,UAAU,CAAC;wBACnChB,MAAMrB;wBACNe,OAAO;wBACPC,gBAAgB;wBAChBC,QAAQ;wBACRd;wBACAe,kBAAkB;oBACpB;oBAEA1B,eAAe;wBACboB;wBACAb;wBACAuB,MAAM;wBACNhB;oBACF;oBAEA,IAAI;wBACF,MAAMf,UAAU;4BACdc,IAAIO,IAAIP,EAAE;4BACVX;4BACA6B,MAAMX;4BACNhB;4BACAG;4BACAyB,cAAc;4BACdC,WAAW;4BACXtB;4BACAC;wBACF;oBACF,EAAE,OAAOsB,KAAK;wBACZxB,QAAQiB,MAAM,CAACQ,KAAK,CAAC,CAAC,YAAY,EAAE3B,WAAW,uBAAuB,CAAC;wBAEvE,MAAM0B;oBACR;oBAEA,IAAI7B,OAAO;wBACTK,QAAQiB,MAAM,CAACC,IAAI,CAAC,CAAC,YAAY,EAAEpB,WAAW,4BAA4B,CAAC;oBAC7E;gBACF;YACF;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/predefinedMigrations/v2-v3/fetchAndResave/index.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\nimport type { Field, Payload, PayloadRequest } from 'payload'\n\nimport { upsertRow } from '@payloadcms/drizzle'\n\nimport type { PostgresAdapter } from '../../../types.js'\nimport type { DocsToResave } from '../types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n db: TransactionPg\n debug: boolean\n docsToResave: DocsToResave\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n payload: Payload\n req: PayloadRequest\n tableName: string\n}\n\nexport const fetchAndResave = async ({\n adapter,\n collectionSlug,\n db,\n debug,\n docsToResave,\n fields,\n globalSlug,\n isVersions,\n payload,\n req,\n tableName,\n}: Args) => {\n for (const [id, rows] of Object.entries(docsToResave)) {\n if (collectionSlug) {\n const collectionConfig = payload.collections[collectionSlug].config\n\n if (collectionConfig) {\n if (isVersions) {\n const doc = await payload.findVersionByID({\n id,\n collection: collectionSlug,\n depth: 0,\n fallbackLocale: null,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n if (debug) {\n payload.logger.info(\n `The collection \"${collectionConfig.slug}\" version with ID ${id} will be migrated`,\n )\n }\n\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n id: doc.id,\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(\n `\"${collectionConfig.slug}\" version with ID ${doc.id} FAILED TO MIGRATE`,\n )\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(\n `\"${collectionConfig.slug}\" version with ID ${doc.id} migrated successfully!`,\n )\n }\n } else {\n const doc = await payload.findByID({\n id,\n collection: collectionSlug,\n depth: 0,\n fallbackLocale: null,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n if (debug) {\n payload.logger.info(\n `The collection \"${collectionConfig.slug}\" with ID ${doc.id} will be migrated`,\n )\n }\n\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n id: doc.id,\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(\n `The collection \"${collectionConfig.slug}\" with ID ${doc.id} has FAILED TO MIGRATE`,\n )\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(\n `The collection \"${collectionConfig.slug}\" with ID ${doc.id} has migrated successfully!`,\n )\n }\n }\n }\n }\n\n if (globalSlug) {\n const globalConfig = payload.config.globals?.find((global) => global.slug === globalSlug)\n\n if (globalConfig) {\n if (isVersions) {\n const { docs } = await payload.findGlobalVersions({\n slug: globalSlug,\n depth: 0,\n fallbackLocale: null,\n limit: 0,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n if (debug) {\n payload.logger.info(`${docs.length} global \"${globalSlug}\" versions will be migrated`)\n }\n\n for (const doc of docs) {\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n id: doc.id,\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(`\"${globalSlug}\" version with ID ${doc.id} FAILED TO MIGRATE`)\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(\n `\"${globalSlug}\" version with ID ${doc.id} migrated successfully!`,\n )\n }\n }\n } else {\n const doc = await payload.findGlobal({\n slug: globalSlug,\n depth: 0,\n fallbackLocale: null,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(`The global \"${globalSlug}\" has FAILED TO MIGRATE`)\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(`The global \"${globalSlug}\" has migrated successfully!`)\n }\n }\n }\n }\n }\n}\n"],"names":["upsertRow","traverseFields","fetchAndResave","adapter","collectionSlug","db","debug","docsToResave","fields","globalSlug","isVersions","payload","req","tableName","id","rows","Object","entries","collectionConfig","collections","config","doc","findVersionByID","collection","depth","fallbackLocale","locale","showHiddenFields","logger","info","slug","path","data","ignoreResult","operation","err","error","findByID","globalConfig","globals","find","global","docs","findGlobalVersions","limit","length","findGlobal"],"mappings":"AAGA,SAASA,SAAS,QAAQ,sBAAqB;AAK/C,SAASC,cAAc,QAAQ,sBAAqB;AAgBpD,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,OAAO,EACPC,cAAc,EACdC,EAAE,EACFC,KAAK,EACLC,YAAY,EACZC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,OAAO,EACPC,GAAG,EACHC,SAAS,EACJ;IACL,KAAK,MAAM,CAACC,IAAIC,KAAK,IAAIC,OAAOC,OAAO,CAACV,cAAe;QACrD,IAAIH,gBAAgB;YAClB,MAAMc,mBAAmBP,QAAQQ,WAAW,CAACf,eAAe,CAACgB,MAAM;YAEnE,IAAIF,kBAAkB;gBACpB,IAAIR,YAAY;oBACd,MAAMW,MAAM,MAAMV,QAAQW,eAAe,CAAC;wBACxCR;wBACAS,YAAYnB;wBACZoB,OAAO;wBACPC,gBAAgB;wBAChBC,QAAQ;wBACRd;wBACAe,kBAAkB;oBACpB;oBAEA,IAAIrB,OAAO;wBACTK,QAAQiB,MAAM,CAACC,IAAI,CACjB,CAAC,gBAAgB,EAAEX,iBAAiBY,IAAI,CAAC,kBAAkB,EAAEhB,GAAG,iBAAiB,CAAC;oBAEtF;oBAEAb,eAAe;wBACboB;wBACAb;wBACAuB,MAAM;wBACNhB;oBACF;oBAEA,IAAI;wBACF,MAAMf,UAAU;4BACdc,IAAIO,IAAIP,EAAE;4BACVX;4BACA6B,MAAMX;4BACNhB;4BACAG;4BACAyB,cAAc;4BACdC,WAAW;4BACXtB;4BACAC;wBACF;oBACF,EAAE,OAAOsB,KAAK;wBACZxB,QAAQiB,MAAM,CAACQ,KAAK,CAClB,CAAC,CAAC,EAAElB,iBAAiBY,IAAI,CAAC,kBAAkB,EAAET,IAAIP,EAAE,CAAC,kBAAkB,CAAC;wBAG1E,MAAMqB;oBACR;oBAEA,IAAI7B,OAAO;wBACTK,QAAQiB,MAAM,CAAC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BAEvE,MAAM0B;oBACR;oBAEA,IAAI7B,OAAO;wBACTK,QAAQiB,MAAM,CAACC,IAAI,CAAC,CAAC,YAAY,EAAEpB,WAAW,4BAA4B,CAAC;oBAC7E;gBACF;YACF;QACF;IACF;AACF,EAAC"}
@@ -1,4 +1,4 @@
1
- import type { Field } from 'payload/types';
1
+ import type { Field } from 'payload';
2
2
  type Args = {
3
3
  doc: Record<string, unknown>;
4
4
  fields: Field[];
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAI1C,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CAChC,CAAA;AAED,eAAO,MAAM,cAAc,wCAAyC,IAAI,SA0MvE,CAAA"}
1
+ {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CAChC,CAAA;AAED,eAAO,MAAM,cAAc,wCAAyC,IAAI,SA0MvE,CAAA"}
@@ -1,4 +1,4 @@
1
- import { tabHasName } from 'payload/types';
1
+ import { tabHasName } from 'payload/shared';
2
2
  export const traverseFields = ({ doc, fields, locale, path, rows })=>{
3
3
  fields.forEach((field)=>{
4
4
  switch(field.type){
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.ts"],"sourcesContent":["import type { Field } from 'payload/types'\n\nimport { tabHasName } from 'payload/types'\n\ntype Args = {\n doc: Record<string, unknown>\n fields: Field[]\n locale?: string\n path: string\n rows: Record<string, unknown>[]\n}\n\nexport const traverseFields = ({ doc, fields, locale, path, rows }: Args) => {\n fields.forEach((field) => {\n switch (field.type) {\n case 'group': {\n const newPath = `${path ? `${path}.` : ''}${field.name}`\n const newDoc = doc?.[field.name]\n\n if (typeof newDoc === 'object' && newDoc !== null) {\n if (field.localized) {\n Object.entries(newDoc).forEach(([locale, localeDoc]) => {\n return traverseFields({\n doc: localeDoc,\n fields: field.fields,\n locale,\n path: newPath,\n rows,\n })\n })\n } else {\n return traverseFields({\n doc: newDoc as Record<string, unknown>,\n fields: field.fields,\n path: newPath,\n rows,\n })\n }\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n return traverseFields({\n doc,\n fields: field.fields,\n path,\n rows,\n })\n }\n\n case 'array': {\n const rowData = doc?.[field.name]\n\n if (field.localized && typeof rowData === 'object' && rowData !== null) {\n Object.entries(rowData).forEach(([locale, localeRows]) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n return traverseFields({\n doc: row as Record<string, unknown>,\n fields: field.fields,\n locale,\n path: `${path ? `${path}.` : ''}${field.name}.${i}`,\n rows,\n })\n })\n }\n })\n }\n\n if (Array.isArray(rowData)) {\n rowData.forEach((row, i) => {\n return traverseFields({\n doc: row as Record<string, unknown>,\n fields: field.fields,\n path: `${path ? `${path}.` : ''}${field.name}.${i}`,\n rows,\n })\n })\n }\n\n break\n }\n\n case 'blocks': {\n const rowData = doc?.[field.name]\n\n if (field.localized && typeof rowData === 'object' && rowData !== null) {\n Object.entries(rowData).forEach(([locale, localeRows]) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n const matchedBlock = field.blocks.find((block) => block.slug === row.blockType)\n\n if (matchedBlock) {\n return traverseFields({\n doc: row as Record<string, unknown>,\n fields: matchedBlock.fields,\n locale,\n path: `${path ? `${path}.` : ''}${field.name}.${i}`,\n rows,\n })\n }\n })\n }\n })\n }\n\n if (Array.isArray(rowData)) {\n rowData.forEach((row, i) => {\n const matchedBlock = field.blocks.find((block) => block.slug === row.blockType)\n\n if (matchedBlock) {\n return traverseFields({\n doc: row as Record<string, unknown>,\n fields: matchedBlock.fields,\n path: `${path ? `${path}.` : ''}${field.name}.${i}`,\n rows,\n })\n }\n })\n }\n\n break\n }\n\n case 'tabs': {\n return field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n const newDoc = doc?.[tab.name]\n const newPath = `${path ? `${path}.` : ''}${tab.name}`\n\n if (typeof newDoc === 'object' && newDoc !== null) {\n if (tab.localized) {\n Object.entries(newDoc).forEach(([locale, localeDoc]) => {\n return traverseFields({\n doc: localeDoc,\n fields: tab.fields,\n locale,\n path: newPath,\n rows,\n })\n })\n } else {\n return traverseFields({\n doc: newDoc as Record<string, unknown>,\n fields: tab.fields,\n path: newPath,\n rows,\n })\n }\n }\n } else {\n traverseFields({\n doc,\n fields: tab.fields,\n path,\n rows,\n })\n }\n })\n }\n\n case 'relationship':\n case 'upload': {\n if (typeof field.relationTo === 'string') {\n if (field.type === 'upload' || !field.hasMany) {\n const relationshipPath = `${path ? `${path}.` : ''}${field.name}`\n\n if (field.localized) {\n const matchedRelationshipsWithLocales = rows.filter(\n (row) => row.path === relationshipPath,\n )\n\n if (matchedRelationshipsWithLocales.length && !doc[field.name]) {\n doc[field.name] = {}\n }\n\n const newDoc = doc[field.name] as Record<string, unknown>\n\n matchedRelationshipsWithLocales.forEach((localeRow) => {\n if (typeof localeRow.locale === 'string') {\n const [, id] = Object.entries(localeRow).find(\n ([key, val]) =>\n val !== null && !['id', 'locale', 'order', 'parent_id', 'path'].includes(key),\n )\n\n newDoc[localeRow.locale] = id\n }\n })\n } else {\n const matchedRelationship = rows.find((row) => {\n const matchesPath = row.path === relationshipPath\n\n if (locale) return matchesPath && locale === row.locale\n\n return row.path === relationshipPath\n })\n\n if (matchedRelationship) {\n const [, id] = Object.entries(matchedRelationship).find(\n ([key, val]) =>\n val !== null && !['id', 'locale', 'order', 'parent_id', 'path'].includes(key),\n )\n\n doc[field.name] = id\n }\n }\n }\n }\n }\n }\n })\n}\n"],"names":["tabHasName","traverseFields","doc","fields","locale","path","rows","forEach","field","type","newPath","name","newDoc","localized","Object","entries","localeDoc","rowData","localeRows","Array","isArray","row","i","matchedBlock","blocks","find","block","slug","blockType","tabs","tab","relationTo","hasMany","relationshipPath","matchedRelationshipsWithLocales","filter","length","localeRow","id","key","val","includes","matchedRelationship","matchesPath"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,UAAU,QAAQ,gBAAe;AAU1C,OAAO,MAAMC,iBAAiB,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAQ;IACtEH,OAAOI,OAAO,CAAC,CAACC;QACd,OAAQA,MAAMC,IAAI;YAChB,KAAK;gBAAS;oBACZ,MAAMC,UAAU,CAAC,EAAEL,OAAO,CAAC,EAAEA,KAAK,CAAC,CAAC,GAAG,GAAG,EAAEG,MAAMG,IAAI,CAAC,CAAC;oBACxD,MAAMC,SAASV,KAAK,CAACM,MAAMG,IAAI,CA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AAE;oCAC9DT,GAAG,CAACM,MAAMG,IAAI,CAAC,GAAG,CAAC;gCACrB;gCAEA,MAAMC,SAASV,GAAG,CAACM,MAAMG,IAAI,CAAC;gCAE9BuB,gCAAgC3B,OAAO,CAAC,CAAC8B;oCACvC,IAAI,OAAOA,UAAUjC,MAAM,KAAK,UAAU;wCACxC,MAAM,GAAGkC,GAAG,GAAGxB,OAAOC,OAAO,CAACsB,WAAWZ,IAAI,CAC3C,CAAC,CAACc,KAAKC,IAAI,GACTA,QAAQ,QAAQ,CAAC;gDAAC;gDAAM;gDAAU;gDAAS;gDAAa;6CAAO,CAACC,QAAQ,CAACF;wCAG7E3B,MAAM,CAACyB,UAAUjC,MAAM,CAAC,GAAGkC;oCAC7B;gCACF;4BACF,OAAO;gCACL,MAAMI,sBAAsBpC,KAAKmB,IAAI,CAAC,CAACJ;oCACrC,MAAMsB,cAActB,IAAIhB,IAAI,KAAK4B;oCAEjC,IAAI7B,QAAQ,OAAOuC,eAAevC,WAAWiB,IAAIjB,MAAM;oCAEvD,OAAOiB,IAAIhB,IAAI,KAAK4B;gCACtB;gCAEA,IAAIS,qBAAqB;oCACvB,MAAM,GAAGJ,GAAG,GAAGxB,OAAOC,OAAO,CAAC2B,qBAAqBjB,IAAI,CACrD,CAAC,CAACc,KAAKC,IAAI,GACTA,QAAQ,QAAQ,CAAC;4CAAC;4CAAM;4CAAU;4CAAS;4CAAa;yCAAO,CAACC,QAAQ,CAACF;oCAG7ErC,GAAG,CAACM,MAAMG,IAAI,CAAC,GAAG2B;gCACpB;4BACF;wBACF;oBACF;gBACF;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nimport { tabHasName } from 'payload/shared'\n\ntype Args = {\n doc: Record<string, unknown>\n fields: Field[]\n locale?: string\n path: string\n rows: Record<string, unknown>[]\n}\n\nexport const traverseFields = ({ doc, fields, locale, path, rows }: Args) => {\n fields.forEach((field) => {\n switch (field.type) {\n case 'group': {\n const newPath = `${path ? `${path}.` : ''}${field.name}`\n const newDoc = doc?.[field.name]\n\n if (typeof newDoc === 'object' && newDoc !== null) {\n if (field.localized) {\n Object.entries(newDoc).forEach(([locale, localeDoc]) => {\n return traverseFields({\n doc: localeDoc,\n fields: field.fields,\n locale,\n path: newPath,\n rows,\n })\n })\n } else {\n return traverseFields({\n doc: newDoc as Record<string, unknown>,\n fields: field.fields,\n path: newPath,\n rows,\n })\n }\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n return traverseFields({\n doc,\n fields: field.fields,\n path,\n rows,\n })\n }\n\n case 'array': {\n const rowData = doc?.[field.name]\n\n if (field.localized && typeof rowData === 'object' && rowData !== null) {\n Object.entries(rowData).forEach(([locale, localeRows]) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n return traverseFields({\n doc: row as Record<string, unknown>,\n fields: field.fields,\n locale,\n path: `${path ? `${path}.` : ''}${field.name}.${i}`,\n rows,\n })\n })\n }\n })\n }\n\n if (Array.isArray(rowData)) {\n rowData.forEach((row, i) => {\n return traverseFields({\n doc: row as Record<string, unknown>,\n fields: field.fields,\n path: `${path ? `${path}.` : ''}${field.name}.${i}`,\n rows,\n })\n })\n }\n\n break\n }\n\n case 'blocks': {\n const rowData = doc?.[field.name]\n\n if (field.localized && typeof rowData === 'object' && rowData !== null) {\n Object.entries(rowData).forEach(([locale, localeRows]) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n const matchedBlock = field.blocks.find((block) => block.slug === row.blockType)\n\n if (matchedBlock) {\n return traverseFields({\n doc: row as Record<string, unknown>,\n fields: matchedBlock.fields,\n locale,\n path: `${path ? `${path}.` : ''}${field.name}.${i}`,\n rows,\n })\n }\n })\n }\n })\n }\n\n if (Array.isArray(rowData)) {\n rowData.forEach((row, i) => {\n const matchedBlock = field.blocks.find((block) => block.slug === row.blockType)\n\n if (matchedBlock) {\n return traverseFields({\n doc: row as Record<string, unknown>,\n fields: matchedBlock.fields,\n path: `${path ? `${path}.` : ''}${field.name}.${i}`,\n rows,\n })\n }\n })\n }\n\n break\n }\n\n case 'tabs': {\n return field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n const newDoc = doc?.[tab.name]\n const newPath = `${path ? `${path}.` : ''}${tab.name}`\n\n if (typeof newDoc === 'object' && newDoc !== null) {\n if (tab.localized) {\n Object.entries(newDoc).forEach(([locale, localeDoc]) => {\n return traverseFields({\n doc: localeDoc,\n fields: tab.fields,\n locale,\n path: newPath,\n rows,\n })\n })\n } else {\n return traverseFields({\n doc: newDoc as Record<string, unknown>,\n fields: tab.fields,\n path: newPath,\n rows,\n })\n }\n }\n } else {\n traverseFields({\n doc,\n fields: tab.fields,\n path,\n rows,\n })\n }\n })\n }\n\n case 'relationship':\n case 'upload': {\n if (typeof field.relationTo === 'string') {\n if (field.type === 'upload' || !field.hasMany) {\n const relationshipPath = `${path ? `${path}.` : ''}${field.name}`\n\n if (field.localized) {\n const matchedRelationshipsWithLocales = rows.filter(\n (row) => row.path === relationshipPath,\n )\n\n if (matchedRelationshipsWithLocales.length && !doc[field.name]) {\n doc[field.name] = {}\n }\n\n const newDoc = doc[field.name] as Record<string, unknown>\n\n matchedRelationshipsWithLocales.forEach((localeRow) => {\n if (typeof localeRow.locale === 'string') {\n const [, id] = Object.entries(localeRow).find(\n ([key, val]) =>\n val !== null && !['id', 'locale', 'order', 'parent_id', 'path'].includes(key),\n )\n\n newDoc[localeRow.locale] = id\n }\n })\n } else {\n const matchedRelationship = rows.find((row) => {\n const matchesPath = row.path === relationshipPath\n\n if (locale) return matchesPath && locale === row.locale\n\n return row.path === relationshipPath\n })\n\n if (matchedRelationship) {\n const [, id] = Object.entries(matchedRelationship).find(\n ([key, val]) =>\n val !== null && !['id', 'locale', 'order', 'parent_id', 'path'].includes(key),\n )\n\n doc[field.name] = id\n }\n }\n }\n }\n }\n }\n })\n}\n"],"names":["tabHasName","traverseFields","doc","fields","locale","path","rows","forEach","field","type","newPath","name","newDoc","localized","Object","entries","localeDoc","rowData","localeRows","Array","isArray","row","i","matchedBlock","blocks","find","block","slug","blockType","tabs","tab","relationTo","hasMany","relationshipPath","matchedRelationshipsWithLocales","filter","length","localeRow","id","key","val","includes","matchedRelationship","matchesPath"],"mappings":"AAEA,SAASA,UAAU,QAAQ,iBAAgB;AAU3C,OAAO,MAAMC,iBAAiB,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAQ;IACtEH,OAAOI,OAAO,CAAC,CAACC;QACd,OAAQA,MAAMC,IAAI;YAChB,KAAK;gBAAS;oBACZ,MAAMC,UAAU,CAAC,EAAEL,OAAO,CAAC,EAAEA,KAAK,CAAC,CAAC,GAAG,GAAG,EAAEG,MAAMG,IAAI,CAAC,CAAC;oBACxD,MAAMC,SAASV,KAAK,CAACM,MAAMG,IAAI,CAAC;oBAEhC,IAAI,OAAOC,WAAW,YAAYA,WAAW,MAAM;wBACjD,IAAIJ,MAAMK,SAAS,EAAE;4BACnBC,OAAOC,OAAO,CAACH,QAAQL,OAAO,CAAC,CAAC,CAACH,QAAQY,UAAU;gCACjD,OAAOf,eAAe;oCACpBC,KAAKc;oCACLb,QAAQK,MAAML,MAAM;oCACpBC;oCACAC,MAAMK;oCACNJ;gCACF;4BACF;wBACF,OAAO;4BACL,OAAOL,eAAe;gCACpBC,KAAKU;gCACLT,QAAQK,MAAML,MAAM;gCACpBE,MAAMK;gCACNJ;4BACF;wBACF;oBACF;oBAEA;gBACF;YAEA,KAAK;YACL,KAAK;gBAAe;oBAClB,OAAOL,eAAe;wBACpBC;wBACAC,QAAQK,MAAML,MAAM;wBACpBE;wBACAC;oBACF;gBACF;YAEA,KAAK;gBAAS;oBACZ,MAAMW,UAAUf,KAAK,CAACM,MAAMG,IAAI,CAAC;oBAEjC,IAAIH,MAAMK,SAAS,IAAI,OAAOI,YAAY,YAAYA,YAAY,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AEvD,OAAOiB,IAAIhB,IAAI,KAAK4B;gCACtB;gCAEA,IAAIS,qBAAqB;oCACvB,MAAM,GAAGJ,GAAG,GAAGxB,OAAOC,OAAO,CAAC2B,qBAAqBjB,IAAI,CACrD,CAAC,CAACc,KAAKC,IAAI,GACTA,QAAQ,QAAQ,CAAC;4CAAC;4CAAM;4CAAU;4CAAS;4CAAa;yCAAO,CAACC,QAAQ,CAACF;oCAG7ErC,GAAG,CAACM,MAAMG,IAAI,CAAC,GAAG2B;gCACpB;4BACF;wBACF;oBACF;gBACF;QACF;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"groupUpSQLStatements.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/groupUpSQLStatements.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GACd,WAAW,GACX,eAAe,GACf,YAAY,GACZ,gBAAgB,GAChB,WAAW,GACX,SAAS,CAAA;AAgBb,eAAO,MAAM,oBAAoB,SAAU,MAAM,EAAE,KAAG,OAAO,MAAM,EAAE,MAAM,EAAE,CAmD5E,CAAA"}
1
+ {"version":3,"file":"groupUpSQLStatements.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/groupUpSQLStatements.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GACd,WAAW,GACX,eAAe,GACf,YAAY,GACZ,gBAAgB,GAChB,WAAW,GACX,SAAS,CAAA;AAgBb,eAAO,MAAM,oBAAoB,SAAU,MAAM,EAAE,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAmD5E,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/groupUpSQLStatements.ts"],"sourcesContent":["export type Groups =\n | 'addColumn'\n | 'addConstraint'\n | 'dropColumn'\n | 'dropConstraint'\n | 'dropTable'\n | 'notNull'\n\n/**\n * Convert an \"ADD COLUMN\" statement to an \"ALTER COLUMN\" statement\n * example: ALTER TABLE \"pages_blocks_my_block\" ADD COLUMN \"person_id\" integer NOT NULL;\n * to: ALTER TABLE \"pages_blocks_my_block\" ALTER COLUMN \"person_id\" SET NOT NULL;\n * @param sql\n */\nfunction convertAddColumnToAlterColumn(sql) {\n // Regular expression to match the ADD COLUMN statement with its constraints\n const regex = /ALTER TABLE (\"[^\"]+\") ADD COLUMN (\"[^\"]+\") [\\w\\s]+ NOT NULL;/\n\n // Replace the matched part with \"ALTER COLUMN ... SET NOT NULL;\"\n return sql.replace(regex, 'ALTER TABLE $1 ALTER COLUMN $2 SET NOT NULL;')\n}\n\nexport const groupUpSQLStatements = (list: string[]): Record<Groups, string[]> => {\n const groups = {\n addColumn: 'ADD COLUMN',\n // example: ALTER TABLE \"posts\" ADD COLUMN \"category_id\" integer\n\n addConstraint: 'ADD CONSTRAINT',\n //example:\n // DO $$ BEGIN\n // ALTER TABLE \"pages_blocks_my_block\" ADD CONSTRAINT \"pages_blocks_my_block_person_id_users_id_fk\" FOREIGN KEY (\"person_id\") REFERENCES \"users\"(\"id\") ON DELETE cascade ON UPDATE no action;\n // EXCEPTION\n // WHEN duplicate_object THEN null;\n // END $$;\n\n dropColumn: 'DROP COLUMN',\n // example: ALTER TABLE \"_posts_v_rels\" DROP COLUMN IF EXISTS \"posts_id\";\n\n dropConstraint: 'DROP CONSTRAINT',\n // example: ALTER TABLE \"_posts_v_rels\" DROP CONSTRAINT \"_posts_v_rels_posts_fk\";\n\n dropTable: 'DROP TABLE',\n // example: DROP TABLE \"pages_rels\";\n\n notNull: 'NOT NULL',\n // example: ALTER TABLE \"pages_blocks_my_block\" ALTER COLUMN \"person_id\" SET NOT NULL;\n }\n\n const result = Object.keys(groups).reduce((result, group: Groups) => {\n result[group] = []\n return result\n }, {}) as Record<Groups, string[]>\n\n for (const line of list) {\n Object.entries(groups).some(([key, value]) => {\n if (line.endsWith('NOT NULL;')) {\n // split up the ADD COLUMN and ALTER COLUMN NOT NULL statements\n // example: ALTER TABLE \"pages_blocks_my_block\" ADD COLUMN \"person_id\" integer NOT NULL;\n // becomes two separate statements:\n // 1. ALTER TABLE \"pages_blocks_my_block\" ADD COLUMN \"person_id\" integer;\n // 2. ALTER TABLE \"pages_blocks_my_block\" ALTER COLUMN \"person_id\" SET NOT NULL;\n result.addColumn.push(line.replace(' NOT NULL;', ';'))\n result.notNull.push(convertAddColumnToAlterColumn(line))\n return true\n }\n if (line.includes(value)) {\n result[key].push(line)\n return true\n }\n })\n }\n\n return result\n}\n"],"names":["convertAddColumnToAlterColumn","sql","regex","replace","groupUpSQLStatements","list","groups","addColumn","addConstraint","dropColumn","dropConstraint","dropTable","notNull","result","Object","keys","reduce","group","line","entries","some","key","value","endsWith","push","includes"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAQA;;;;;CAKC,GACD,SAASA,8BAA8BC,GAAG;IACxC,4EAA4E;IAC5E,MAAMC,QAAQ;IAEd,iEAAiE;IACjE,OAAOD,IAAIE,OAAO,CAACD,OAAO;AAC5B;AAEA,OAAO,MAAME,uBAAuB,CAACC;IACnC,MAAMC,SAAS;QACbC,WAAW;QACX,gEAAgE;QAEhEC,eAAe;QACf,UAAU;QACV,cAAc;QACd,8LAA8L;QAC9L,YAAY;QACZ,oCAAoC;QACpC,UAAU;QAEVC,YAAY;QACZ,yEAAyE;QAEzEC,gBAAgB;QAChB,iFAAiF;QAEjFC,WAAW;QACX,oCAAoC;QAEpCC,SAAS;IAEX;IAEA,MAAMC,SAASC,OAAOC,IAAI,CAACT,QAAQU,MAAM,CAAC,CAACH,QAAQI;QACjDJ,MAAM,CAACI,MAAM,GAAG,EAAE;QAClB,OAAOJ;IACT,GAAG,CAAC;IAEJ,KAAK,MAAMK,QAAQb,KAAM;QACvBS,OAAOK,OAAO,CAACb,QAAQc,IAAI,CAAC,CAAC,CAACC,KAAKC,MAAM;YACvC,IAAIJ,KAAKK,QAAQ,CAAC,cAAc;gBAC9B,+DAA+D;gBAC/D,wFAAwF;gBACxF,mCAAmC;gBACnC,0EAA0E;gBAC1E,kFAAkF;gBAClFV,OAAON,SAAS,CAACiB,IAAI,CAACN,KAAKf,OAAO,CAAC,cAAc;gBACjDU,OAAOD,OAAO,CAACY,IAAI,CAACxB,8BAA8BkB;gBAClD,OAAO;YACT;YACA,IAAIA,KAAKO,QAAQ,CAACH,QAAQ;gBACxBT,MAAM,CAACQ,IAAI,CAACG,IAAI,CAACN;gBACjB,OAAO;YACT;QACF;IACF;IAEA,OAAOL;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/groupUpSQLStatements.ts"],"sourcesContent":["export type Groups =\n | 'addColumn'\n | 'addConstraint'\n | 'dropColumn'\n | 'dropConstraint'\n | 'dropTable'\n | 'notNull'\n\n/**\n * Convert an \"ADD COLUMN\" statement to an \"ALTER COLUMN\" statement\n * example: ALTER TABLE \"pages_blocks_my_block\" ADD COLUMN \"person_id\" integer NOT NULL;\n * to: ALTER TABLE \"pages_blocks_my_block\" ALTER COLUMN \"person_id\" SET NOT NULL;\n * @param sql\n */\nfunction convertAddColumnToAlterColumn(sql) {\n // Regular expression to match the ADD COLUMN statement with its constraints\n const regex = /ALTER TABLE (\"[^\"]+\") ADD COLUMN (\"[^\"]+\") [\\w\\s]+ NOT NULL;/\n\n // Replace the matched part with \"ALTER COLUMN ... SET NOT NULL;\"\n return sql.replace(regex, 'ALTER TABLE $1 ALTER COLUMN $2 SET NOT NULL;')\n}\n\nexport const groupUpSQLStatements = (list: string[]): Record<Groups, string[]> => {\n const groups = {\n addColumn: 'ADD COLUMN',\n // example: ALTER TABLE \"posts\" ADD COLUMN \"category_id\" integer\n\n addConstraint: 'ADD CONSTRAINT',\n //example:\n // DO $$ BEGIN\n // ALTER TABLE \"pages_blocks_my_block\" ADD CONSTRAINT \"pages_blocks_my_block_person_id_users_id_fk\" FOREIGN KEY (\"person_id\") REFERENCES \"users\"(\"id\") ON DELETE cascade ON UPDATE no action;\n // EXCEPTION\n // WHEN duplicate_object THEN null;\n // END $$;\n\n dropColumn: 'DROP COLUMN',\n // example: ALTER TABLE \"_posts_v_rels\" DROP COLUMN IF EXISTS \"posts_id\";\n\n dropConstraint: 'DROP CONSTRAINT',\n // example: ALTER TABLE \"_posts_v_rels\" DROP CONSTRAINT \"_posts_v_rels_posts_fk\";\n\n dropTable: 'DROP TABLE',\n // example: DROP TABLE \"pages_rels\";\n\n notNull: 'NOT NULL',\n // example: ALTER TABLE \"pages_blocks_my_block\" ALTER COLUMN \"person_id\" SET NOT NULL;\n }\n\n const result = Object.keys(groups).reduce((result, group: Groups) => {\n result[group] = []\n return result\n }, {}) as Record<Groups, string[]>\n\n for (const line of list) {\n Object.entries(groups).some(([key, value]) => {\n if (line.endsWith('NOT NULL;')) {\n // split up the ADD COLUMN and ALTER COLUMN NOT NULL statements\n // example: ALTER TABLE \"pages_blocks_my_block\" ADD COLUMN \"person_id\" integer NOT NULL;\n // becomes two separate statements:\n // 1. ALTER TABLE \"pages_blocks_my_block\" ADD COLUMN \"person_id\" integer;\n // 2. ALTER TABLE \"pages_blocks_my_block\" ALTER COLUMN \"person_id\" SET NOT NULL;\n result.addColumn.push(line.replace(' NOT NULL;', ';'))\n result.notNull.push(convertAddColumnToAlterColumn(line))\n return true\n }\n if (line.includes(value)) {\n result[key].push(line)\n return true\n }\n })\n }\n\n return result\n}\n"],"names":["convertAddColumnToAlterColumn","sql","regex","replace","groupUpSQLStatements","list","groups","addColumn","addConstraint","dropColumn","dropConstraint","dropTable","notNull","result","Object","keys","reduce","group","line","entries","some","key","value","endsWith","push","includes"],"mappings":"AAQA;;;;;CAKC,GACD,SAASA,8BAA8BC,GAAG;IACxC,4EAA4E;IAC5E,MAAMC,QAAQ;IAEd,iEAAiE;IACjE,OAAOD,IAAIE,OAAO,CAACD,OAAO;AAC5B;AAEA,OAAO,MAAME,uBAAuB,CAACC;IACnC,MAAMC,SAAS;QACbC,WAAW;QACX,gEAAgE;QAEhEC,eAAe;QACf,UAAU;QACV,cAAc;QACd,8LAA8L;QAC9L,YAAY;QACZ,oCAAoC;QACpC,UAAU;QAEVC,YAAY;QACZ,yEAAyE;QAEzEC,gBAAgB;QAChB,iFAAiF;QAEjFC,WAAW;QACX,oCAAoC;QAEpCC,SAAS;IAEX;IAEA,MAAMC,SAASC,OAAOC,IAAI,CAACT,QAAQU,MAAM,CAAC,CAACH,QAAQI;QACjDJ,MAAM,CAACI,MAAM,GAAG,EAAE;QAClB,OAAOJ;IACT,GAAG,CAAC;IAEJ,KAAK,MAAMK,QAAQb,KAAM;QACvBS,OAAOK,OAAO,CAACb,QAAQc,IAAI,CAAC,CAAC,CAACC,KAAKC,MAAM;YACvC,IAAIJ,KAAKK,QAAQ,CAAC,cAAc;gBAC9B,+DAA+D;gBAC/D,wFAAwF;gBACxF,mCAAmC;gBACnC,0EAA0E;gBAC1E,kFAAkF;gBAClFV,OAAON,SAAS,CAACiB,IAAI,CAACN,KAAKf,OAAO,CAAC,cAAc;gBACjDU,OAAOD,OAAO,CAACY,IAAI,CAACxB,8BAA8BkB;gBAClD,OAAO;YACT;YACA,IAAIA,KAAKO,QAAQ,CAACH,QAAQ;gBACxBT,MAAM,CAACQ,IAAI,CAACG,IAAI,CAACN;gBACjB,OAAO;YACT;QACF;IACF;IAEA,OAAOL;AACT,EAAC"}
@@ -1,9 +1,8 @@
1
- import type { Payload } from 'payload';
2
- import type { PayloadRequestWithData } from 'payload/types';
1
+ import type { Payload, PayloadRequest } from 'payload';
3
2
  type Args = {
4
3
  debug?: boolean;
5
4
  payload: Payload;
6
- req?: Partial<PayloadRequestWithData>;
5
+ req?: Partial<PayloadRequest>;
7
6
  };
8
7
  /**
9
8
  * Moves upload and relationship columns from the join table and into the tables while moving data
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAiB3D,KAAK,IAAI,GAAG;IACV,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAA;CACtC,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,4BAAmC,IAAI,kBA8OxE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAiBtD,KAAK,IAAI,GAAG;IACV,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;CAC9B,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB,4BAAmC,IAAI,kBA8OxE,CAAA"}