@payloadcms/db-postgres 3.0.0-beta.7 → 3.0.0-beta.70

Sign up to get free protection for your applications and to get access to all the features.
Files changed (397) hide show
  1. package/README.md +1 -1
  2. package/dist/connect.d.ts +1 -1
  3. package/dist/connect.d.ts.map +1 -1
  4. package/dist/connect.js +16 -13
  5. package/dist/connect.js.map +1 -1
  6. package/dist/countDistinct.d.ts +3 -0
  7. package/dist/countDistinct.d.ts.map +1 -0
  8. package/dist/countDistinct.js +24 -0
  9. package/dist/countDistinct.js.map +1 -0
  10. package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -0
  11. package/dist/createJSONQuery/convertPathToJSONTraversal.js.map +1 -0
  12. package/dist/createJSONQuery/formatJSONPathSegment.d.ts.map +1 -0
  13. package/dist/createJSONQuery/formatJSONPathSegment.js.map +1 -0
  14. package/dist/createJSONQuery/index.d.ts.map +1 -0
  15. package/dist/createJSONQuery/index.js.map +1 -0
  16. package/dist/createMigration.d.ts +1 -1
  17. package/dist/createMigration.d.ts.map +1 -1
  18. package/dist/createMigration.js +56 -57
  19. package/dist/createMigration.js.map +1 -1
  20. package/dist/defaultSnapshot.d.ts +3 -0
  21. package/dist/defaultSnapshot.d.ts.map +1 -0
  22. package/dist/defaultSnapshot.js +16 -0
  23. package/dist/defaultSnapshot.js.map +1 -0
  24. package/dist/deleteWhere.d.ts +3 -0
  25. package/dist/deleteWhere.d.ts.map +1 -0
  26. package/dist/deleteWhere.js +6 -0
  27. package/dist/deleteWhere.js.map +1 -0
  28. package/dist/dropDatabase.d.ts +3 -0
  29. package/dist/dropDatabase.d.ts.map +1 -0
  30. package/dist/dropDatabase.js +9 -0
  31. package/dist/dropDatabase.js.map +1 -0
  32. package/dist/execute.d.ts +3 -0
  33. package/dist/execute.d.ts.map +1 -0
  34. package/dist/execute.js +11 -0
  35. package/dist/execute.js.map +1 -0
  36. package/dist/exports/migration-utils.d.ts +2 -0
  37. package/dist/exports/migration-utils.d.ts.map +1 -0
  38. package/dist/exports/migration-utils.js +3 -0
  39. package/dist/exports/migration-utils.js.map +1 -0
  40. package/dist/getMigrationTemplate.d.ts +3 -0
  41. package/dist/getMigrationTemplate.d.ts.map +1 -0
  42. package/dist/getMigrationTemplate.js +12 -0
  43. package/dist/getMigrationTemplate.js.map +1 -0
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +44 -71
  47. package/dist/index.js.map +1 -1
  48. package/dist/init.d.ts +1 -1
  49. package/dist/init.d.ts.map +1 -1
  50. package/dist/init.js +21 -24
  51. package/dist/init.js.map +1 -1
  52. package/dist/insert.d.ts +3 -0
  53. package/dist/insert.d.ts.map +1 -0
  54. package/dist/insert.js +12 -0
  55. package/dist/insert.js.map +1 -0
  56. package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
  57. package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
  58. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
  59. package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
  60. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +20 -0
  61. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
  62. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +169 -0
  63. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
  64. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
  65. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
  66. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +191 -0
  67. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
  68. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
  69. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
  70. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
  71. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
  72. package/dist/predefinedMigrations/v2-v3/index.d.ts +23 -0
  73. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
  74. package/dist/predefinedMigrations/v2-v3/index.js +211 -0
  75. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
  76. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +20 -0
  77. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
  78. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
  79. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
  80. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +23 -0
  81. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
  82. package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
  83. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
  84. package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
  85. package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
  86. package/dist/predefinedMigrations/v2-v3/types.js +6 -0
  87. package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
  88. package/dist/requireDrizzleKit.d.ts +3 -0
  89. package/dist/requireDrizzleKit.d.ts.map +1 -0
  90. package/dist/requireDrizzleKit.js +5 -0
  91. package/dist/requireDrizzleKit.js.map +1 -0
  92. package/dist/schema/build.d.ts +12 -7
  93. package/dist/schema/build.d.ts.map +1 -1
  94. package/dist/schema/build.js +209 -125
  95. package/dist/schema/build.js.map +1 -1
  96. package/dist/schema/createIndex.js.map +1 -1
  97. package/dist/schema/idToUUID.d.ts +1 -1
  98. package/dist/schema/idToUUID.d.ts.map +1 -1
  99. package/dist/schema/idToUUID.js.map +1 -1
  100. package/dist/schema/parentIDColumnMap.js.map +1 -1
  101. package/dist/schema/setColumnID.d.ts +1 -1
  102. package/dist/schema/setColumnID.d.ts.map +1 -1
  103. package/dist/schema/setColumnID.js +2 -2
  104. package/dist/schema/setColumnID.js.map +1 -1
  105. package/dist/schema/traverseFields.d.ts +5 -7
  106. package/dist/schema/traverseFields.d.ts.map +1 -1
  107. package/dist/schema/traverseFields.js +148 -66
  108. package/dist/schema/traverseFields.js.map +1 -1
  109. package/dist/types.d.ts +76 -34
  110. package/dist/types.d.ts.map +1 -1
  111. package/dist/types.js.map +1 -1
  112. package/package.json +35 -30
  113. package/dist/create.d.ts +0 -3
  114. package/dist/create.d.ts.map +0 -1
  115. package/dist/create.js +0 -21
  116. package/dist/create.js.map +0 -1
  117. package/dist/createGlobal.d.ts +0 -5
  118. package/dist/createGlobal.d.ts.map +0 -1
  119. package/dist/createGlobal.js +0 -21
  120. package/dist/createGlobal.js.map +0 -1
  121. package/dist/createGlobalVersion.d.ts +0 -6
  122. package/dist/createGlobalVersion.d.ts.map +0 -1
  123. package/dist/createGlobalVersion.js +0 -37
  124. package/dist/createGlobalVersion.js.map +0 -1
  125. package/dist/createVersion.d.ts +0 -5
  126. package/dist/createVersion.d.ts.map +0 -1
  127. package/dist/createVersion.js +0 -48
  128. package/dist/createVersion.js.map +0 -1
  129. package/dist/deleteMany.d.ts +0 -3
  130. package/dist/deleteMany.d.ts.map +0 -1
  131. package/dist/deleteMany.js +0 -31
  132. package/dist/deleteMany.js.map +0 -1
  133. package/dist/deleteOne.d.ts +0 -3
  134. package/dist/deleteOne.d.ts.map +0 -1
  135. package/dist/deleteOne.js +0 -62
  136. package/dist/deleteOne.js.map +0 -1
  137. package/dist/deleteVersions.d.ts +0 -3
  138. package/dist/deleteVersions.d.ts.map +0 -1
  139. package/dist/deleteVersions.js +0 -35
  140. package/dist/deleteVersions.js.map +0 -1
  141. package/dist/destroy.d.ts +0 -3
  142. package/dist/destroy.d.ts.map +0 -1
  143. package/dist/destroy.js +0 -11
  144. package/dist/destroy.js.map +0 -1
  145. package/dist/find/buildFindManyArgs.d.ts +0 -13
  146. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  147. package/dist/find/buildFindManyArgs.js +0 -64
  148. package/dist/find/buildFindManyArgs.js.map +0 -1
  149. package/dist/find/chainMethods.d.ts +0 -16
  150. package/dist/find/chainMethods.d.ts.map +0 -1
  151. package/dist/find/chainMethods.js +0 -12
  152. package/dist/find/chainMethods.js.map +0 -1
  153. package/dist/find/findMany.d.ts +0 -22
  154. package/dist/find/findMany.d.ts.map +0 -1
  155. package/dist/find/findMany.js +0 -163
  156. package/dist/find/findMany.js.map +0 -1
  157. package/dist/find/traverseFields.d.ts +0 -16
  158. package/dist/find/traverseFields.d.ts.map +0 -1
  159. package/dist/find/traverseFields.js +0 -154
  160. package/dist/find/traverseFields.js.map +0 -1
  161. package/dist/find.d.ts +0 -3
  162. package/dist/find.d.ts.map +0 -1
  163. package/dist/find.js +0 -24
  164. package/dist/find.js.map +0 -1
  165. package/dist/findGlobal.d.ts +0 -3
  166. package/dist/findGlobal.d.ts.map +0 -1
  167. package/dist/findGlobal.js +0 -26
  168. package/dist/findGlobal.js.map +0 -1
  169. package/dist/findGlobalVersions.d.ts +0 -3
  170. package/dist/findGlobalVersions.d.ts.map +0 -1
  171. package/dist/findGlobalVersions.js +0 -28
  172. package/dist/findGlobalVersions.js.map +0 -1
  173. package/dist/findOne.d.ts +0 -5
  174. package/dist/findOne.d.ts.map +0 -1
  175. package/dist/findOne.js +0 -24
  176. package/dist/findOne.js.map +0 -1
  177. package/dist/findVersions.d.ts +0 -3
  178. package/dist/findVersions.d.ts.map +0 -1
  179. package/dist/findVersions.js +0 -28
  180. package/dist/findVersions.js.map +0 -1
  181. package/dist/migrate.d.ts +0 -3
  182. package/dist/migrate.d.ts.map +0 -1
  183. package/dist/migrate.js +0 -99
  184. package/dist/migrate.js.map +0 -1
  185. package/dist/migrateDown.d.ts +0 -3
  186. package/dist/migrateDown.d.ts.map +0 -1
  187. package/dist/migrateDown.js +0 -63
  188. package/dist/migrateDown.js.map +0 -1
  189. package/dist/migrateFresh.d.ts +0 -8
  190. package/dist/migrateFresh.d.ts.map +0 -1
  191. package/dist/migrateFresh.js +0 -72
  192. package/dist/migrateFresh.js.map +0 -1
  193. package/dist/migrateRefresh.d.ts +0 -6
  194. package/dist/migrateRefresh.d.ts.map +0 -1
  195. package/dist/migrateRefresh.js +0 -102
  196. package/dist/migrateRefresh.js.map +0 -1
  197. package/dist/migrateReset.d.ts +0 -6
  198. package/dist/migrateReset.d.ts.map +0 -1
  199. package/dist/migrateReset.js +0 -82
  200. package/dist/migrateReset.js.map +0 -1
  201. package/dist/migrateStatus.d.ts +0 -3
  202. package/dist/migrateStatus.d.ts.map +0 -1
  203. package/dist/migrateStatus.js +0 -44
  204. package/dist/migrateStatus.js.map +0 -1
  205. package/dist/queries/buildAndOrConditions.d.ts +0 -17
  206. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  207. package/dist/queries/buildAndOrConditions.js +0 -29
  208. package/dist/queries/buildAndOrConditions.js.map +0 -1
  209. package/dist/queries/buildQuery.d.ts +0 -31
  210. package/dist/queries/buildQuery.d.ts.map +0 -1
  211. package/dist/queries/buildQuery.js +0 -76
  212. package/dist/queries/buildQuery.js.map +0 -1
  213. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  214. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  215. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  216. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  217. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  218. package/dist/queries/createJSONQuery/index.js.map +0 -1
  219. package/dist/queries/getTableColumnFromPath.d.ts +0 -51
  220. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  221. package/dist/queries/getTableColumnFromPath.js +0 -412
  222. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  223. package/dist/queries/operatorMap.d.ts +0 -18
  224. package/dist/queries/operatorMap.d.ts.map +0 -1
  225. package/dist/queries/operatorMap.js +0 -24
  226. package/dist/queries/operatorMap.js.map +0 -1
  227. package/dist/queries/parseParams.d.ts +0 -17
  228. package/dist/queries/parseParams.d.ts.map +0 -1
  229. package/dist/queries/parseParams.js +0 -182
  230. package/dist/queries/parseParams.js.map +0 -1
  231. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  232. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  233. package/dist/queries/sanitizeQueryValue.js +0 -90
  234. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  235. package/dist/queries/selectDistinct.d.ts +0 -23
  236. package/dist/queries/selectDistinct.d.ts.map +0 -1
  237. package/dist/queries/selectDistinct.js +0 -41
  238. package/dist/queries/selectDistinct.js.map +0 -1
  239. package/dist/queryDrafts.d.ts +0 -3
  240. package/dist/queryDrafts.d.ts.map +0 -1
  241. package/dist/queryDrafts.js +0 -45
  242. package/dist/queryDrafts.js.map +0 -1
  243. package/dist/schema/getTableName.d.ts +0 -32
  244. package/dist/schema/getTableName.d.ts.map +0 -1
  245. package/dist/schema/getTableName.js +0 -31
  246. package/dist/schema/getTableName.js.map +0 -1
  247. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -11
  248. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  249. package/dist/schema/validateExistingBlockIsIdentical.js +0 -70
  250. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  251. package/dist/transactions/beginTransaction.d.ts +0 -3
  252. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  253. package/dist/transactions/beginTransaction.js +0 -47
  254. package/dist/transactions/beginTransaction.js.map +0 -1
  255. package/dist/transactions/commitTransaction.d.ts +0 -3
  256. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  257. package/dist/transactions/commitTransaction.js +0 -14
  258. package/dist/transactions/commitTransaction.js.map +0 -1
  259. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  260. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  261. package/dist/transactions/rollbackTransaction.js +0 -13
  262. package/dist/transactions/rollbackTransaction.js.map +0 -1
  263. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  264. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  265. package/dist/transform/read/hasManyNumber.js +0 -10
  266. package/dist/transform/read/hasManyNumber.js.map +0 -1
  267. package/dist/transform/read/hasManyText.d.ts +0 -10
  268. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  269. package/dist/transform/read/hasManyText.js +0 -10
  270. package/dist/transform/read/hasManyText.js.map +0 -1
  271. package/dist/transform/read/index.d.ts +0 -12
  272. package/dist/transform/read/index.d.ts.map +0 -1
  273. package/dist/transform/read/index.js +0 -43
  274. package/dist/transform/read/index.js.map +0 -1
  275. package/dist/transform/read/relationship.d.ts +0 -10
  276. package/dist/transform/read/relationship.d.ts.map +0 -1
  277. package/dist/transform/read/relationship.js +0 -64
  278. package/dist/transform/read/relationship.js.map +0 -1
  279. package/dist/transform/read/traverseFields.d.ts +0 -52
  280. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  281. package/dist/transform/read/traverseFields.js +0 -421
  282. package/dist/transform/read/traverseFields.js.map +0 -1
  283. package/dist/transform/write/array.d.ts +0 -26
  284. package/dist/transform/write/array.d.ts.map +0 -1
  285. package/dist/transform/write/array.js +0 -58
  286. package/dist/transform/write/array.js.map +0 -1
  287. package/dist/transform/write/blocks.d.ts +0 -25
  288. package/dist/transform/write/blocks.d.ts.map +0 -1
  289. package/dist/transform/write/blocks.js +0 -54
  290. package/dist/transform/write/blocks.js.map +0 -1
  291. package/dist/transform/write/index.d.ts +0 -13
  292. package/dist/transform/write/index.d.ts.map +0 -1
  293. package/dist/transform/write/index.js +0 -41
  294. package/dist/transform/write/index.js.map +0 -1
  295. package/dist/transform/write/numbers.d.ts +0 -8
  296. package/dist/transform/write/numbers.d.ts.map +0 -1
  297. package/dist/transform/write/numbers.js +0 -11
  298. package/dist/transform/write/numbers.js.map +0 -1
  299. package/dist/transform/write/relationships.d.ts +0 -10
  300. package/dist/transform/write/relationships.d.ts.map +0 -1
  301. package/dist/transform/write/relationships.js +0 -23
  302. package/dist/transform/write/relationships.js.map +0 -1
  303. package/dist/transform/write/selects.d.ts +0 -8
  304. package/dist/transform/write/selects.d.ts.map +0 -1
  305. package/dist/transform/write/selects.js +0 -20
  306. package/dist/transform/write/selects.js.map +0 -1
  307. package/dist/transform/write/texts.d.ts +0 -8
  308. package/dist/transform/write/texts.d.ts.map +0 -1
  309. package/dist/transform/write/texts.js +0 -11
  310. package/dist/transform/write/texts.js.map +0 -1
  311. package/dist/transform/write/traverseFields.d.ts +0 -50
  312. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  313. package/dist/transform/write/traverseFields.js +0 -428
  314. package/dist/transform/write/traverseFields.js.map +0 -1
  315. package/dist/transform/write/types.d.ts +0 -43
  316. package/dist/transform/write/types.d.ts.map +0 -1
  317. package/dist/transform/write/types.js +0 -3
  318. package/dist/transform/write/types.js.map +0 -1
  319. package/dist/update.d.ts +0 -3
  320. package/dist/update.d.ts.map +0 -1
  321. package/dist/update.js +0 -58
  322. package/dist/update.js.map +0 -1
  323. package/dist/updateGlobal.d.ts +0 -5
  324. package/dist/updateGlobal.d.ts.map +0 -1
  325. package/dist/updateGlobal.js +0 -28
  326. package/dist/updateGlobal.js.map +0 -1
  327. package/dist/updateGlobalVersion.d.ts +0 -5
  328. package/dist/updateGlobalVersion.d.ts.map +0 -1
  329. package/dist/updateGlobalVersion.js +0 -40
  330. package/dist/updateGlobalVersion.js.map +0 -1
  331. package/dist/updateVersion.d.ts +0 -5
  332. package/dist/updateVersion.d.ts.map +0 -1
  333. package/dist/updateVersion.js +0 -40
  334. package/dist/updateVersion.js.map +0 -1
  335. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  336. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  337. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  338. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  339. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  340. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  341. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  342. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  343. package/dist/upsertRow/index.d.ts +0 -4
  344. package/dist/upsertRow/index.d.ts.map +0 -1
  345. package/dist/upsertRow/index.js +0 -276
  346. package/dist/upsertRow/index.js.map +0 -1
  347. package/dist/upsertRow/insertArrays.d.ts +0 -13
  348. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  349. package/dist/upsertRow/insertArrays.js +0 -68
  350. package/dist/upsertRow/insertArrays.js.map +0 -1
  351. package/dist/upsertRow/types.d.ts +0 -27
  352. package/dist/upsertRow/types.d.ts.map +0 -1
  353. package/dist/upsertRow/types.js +0 -3
  354. package/dist/upsertRow/types.js.map +0 -1
  355. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  356. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  357. package/dist/utilities/appendPrefixToKeys.js +0 -6
  358. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  359. package/dist/utilities/createBlocksMap.d.ts +0 -5
  360. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  361. package/dist/utilities/createBlocksMap.js +0 -29
  362. package/dist/utilities/createBlocksMap.js.map +0 -1
  363. package/dist/utilities/createMigrationTable.d.ts +0 -3
  364. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  365. package/dist/utilities/createMigrationTable.js +0 -13
  366. package/dist/utilities/createMigrationTable.js.map +0 -1
  367. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  368. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  369. package/dist/utilities/createRelationshipMap.js +0 -19
  370. package/dist/utilities/createRelationshipMap.js.map +0 -1
  371. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  372. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  373. package/dist/utilities/hasLocalesTable.js +0 -11
  374. package/dist/utilities/hasLocalesTable.js.map +0 -1
  375. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  376. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  377. package/dist/utilities/isArrayOfRows.js +0 -5
  378. package/dist/utilities/isArrayOfRows.js.map +0 -1
  379. package/dist/utilities/migrationTableExists.d.ts +0 -3
  380. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  381. package/dist/utilities/migrationTableExists.js +0 -9
  382. package/dist/utilities/migrationTableExists.js.map +0 -1
  383. package/dist/utilities/parseError.d.ts +0 -5
  384. package/dist/utilities/parseError.d.ts.map +0 -1
  385. package/dist/utilities/parseError.js +0 -17
  386. package/dist/utilities/parseError.js.map +0 -1
  387. package/dist/utilities/pushDevSchema.d.ts +0 -9
  388. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  389. package/dist/utilities/pushDevSchema.js +0 -58
  390. package/dist/utilities/pushDevSchema.js.map +0 -1
  391. package/src/index.ts +0 -156
  392. /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.d.ts +0 -0
  393. /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.js +0 -0
  394. /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.d.ts +0 -0
  395. /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.js +0 -0
  396. /package/dist/{queries/createJSONQuery → createJSONQuery}/index.d.ts +0 -0
  397. /package/dist/{queries/createJSONQuery → createJSONQuery}/index.js +0 -0
package/dist/index.js CHANGED
@@ -1,51 +1,45 @@
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 { createDatabaseAdapter } from 'payload';
4
3
  import { connect } from './connect.js';
5
- import { create } from './create.js';
6
- import { createGlobal } from './createGlobal.js';
7
- import { createGlobalVersion } from './createGlobalVersion.js';
4
+ import { countDistinct } from './countDistinct.js';
5
+ import { convertPathToJSONTraversal } from './createJSONQuery/convertPathToJSONTraversal.js';
6
+ import { createJSONQuery } from './createJSONQuery/index.js';
8
7
  import { createMigration } from './createMigration.js';
9
- import { createVersion } from './createVersion.js';
10
- import { deleteMany } from './deleteMany.js';
11
- import { deleteOne } from './deleteOne.js';
12
- import { deleteVersions } from './deleteVersions.js';
13
- import { destroy } from './destroy.js';
14
- import { find } from './find.js';
15
- import { findGlobal } from './findGlobal.js';
16
- import { findGlobalVersions } from './findGlobalVersions.js';
17
- import { findOne } from './findOne.js';
18
- import { findVersions } from './findVersions.js';
8
+ import { defaultDrizzleSnapshot } from './defaultSnapshot.js';
9
+ import { deleteWhere } from './deleteWhere.js';
10
+ import { dropDatabase } from './dropDatabase.js';
11
+ import { execute } from './execute.js';
12
+ import { getMigrationTemplate } from './getMigrationTemplate.js';
19
13
  import { init } from './init.js';
20
- import { migrate } from './migrate.js';
21
- import { migrateDown } from './migrateDown.js';
22
- import { migrateFresh } from './migrateFresh.js';
23
- import { migrateRefresh } from './migrateRefresh.js';
24
- import { migrateReset } from './migrateReset.js';
25
- import { migrateStatus } from './migrateStatus.js';
26
- import { queryDrafts } from './queryDrafts.js';
27
- import { beginTransaction } from './transactions/beginTransaction.js';
28
- import { commitTransaction } from './transactions/commitTransaction.js';
29
- import { rollbackTransaction } from './transactions/rollbackTransaction.js';
30
- import { updateOne } from './update.js';
31
- import { updateGlobal } from './updateGlobal.js';
32
- import { updateGlobalVersion } from './updateGlobalVersion.js';
33
- import { updateVersion } from './updateVersion.js';
14
+ import { insert } from './insert.js';
15
+ import { requireDrizzleKit } from './requireDrizzleKit.js';
34
16
  export { sql } from 'drizzle-orm';
35
17
  export function postgresAdapter(args) {
18
+ const postgresIDType = args.idType || 'serial';
19
+ const payloadIDType = postgresIDType === 'serial' ? 'number' : 'text';
36
20
  function adapter({ payload }) {
37
21
  const migrationDir = findMigrationDir(args.migrationDir);
38
- const idType = args.idType || 'serial';
22
+ let resolveInitializing;
23
+ let rejectInitializing;
24
+ const initializing = new Promise((res, rej)=>{
25
+ resolveInitializing = res;
26
+ rejectInitializing = rej;
27
+ });
39
28
  return createDatabaseAdapter({
40
29
  name: 'postgres',
41
- // Postgres-specific
42
- blockTableNames: {},
30
+ defaultDrizzleSnapshot,
43
31
  drizzle: undefined,
44
32
  enums: {},
33
+ features: {
34
+ json: true
35
+ },
45
36
  fieldConstraints: {},
46
- idType,
37
+ getMigrationTemplate,
38
+ idType: postgresIDType,
39
+ initializing,
47
40
  localesSuffix: args.localesSuffix || '_locales',
48
41
  logger: args.logger,
42
+ operators: operatorMap,
49
43
  pgSchema: undefined,
50
44
  pool: undefined,
51
45
  poolOptions: args.pool,
@@ -55,30 +49,38 @@ export function postgresAdapter(args) {
55
49
  schema: {},
56
50
  schemaName: args.schemaName,
57
51
  sessions: {},
52
+ tableNameMap: new Map(),
58
53
  tables: {},
54
+ transactionOptions: args.transactionOptions || undefined,
59
55
  versionsSuffix: args.versionsSuffix || '_v',
60
56
  // DatabaseAdapter
61
- beginTransaction,
57
+ beginTransaction: args.transactionOptions === false ? undefined : beginTransaction,
62
58
  commitTransaction,
63
59
  connect,
60
+ convertPathToJSONTraversal,
61
+ count,
62
+ countDistinct,
64
63
  create,
65
64
  createGlobal,
66
65
  createGlobalVersion,
66
+ createJSONQuery,
67
67
  createMigration,
68
68
  createVersion,
69
- /**
70
- * This represents how a default ID is treated in Payload as were a field type
71
- */ defaultIDType: idType === 'serial' ? 'number' : 'text',
69
+ defaultIDType: payloadIDType,
72
70
  deleteMany,
73
71
  deleteOne,
74
72
  deleteVersions,
73
+ deleteWhere,
75
74
  destroy,
75
+ dropDatabase,
76
+ execute,
76
77
  find,
77
78
  findGlobal,
78
79
  findGlobalVersions,
79
80
  findOne,
80
81
  findVersions,
81
82
  init,
83
+ insert,
82
84
  migrate,
83
85
  migrateDown,
84
86
  migrateFresh,
@@ -88,6 +90,9 @@ export function postgresAdapter(args) {
88
90
  migrationDir,
89
91
  payload,
90
92
  queryDrafts,
93
+ rejectInitializing,
94
+ requireDrizzleKit,
95
+ resolveInitializing,
91
96
  rollbackTransaction,
92
97
  updateGlobal,
93
98
  updateGlobalVersion,
@@ -96,41 +101,9 @@ export function postgresAdapter(args) {
96
101
  });
97
102
  }
98
103
  return {
99
- defaultIDType: 'number',
104
+ defaultIDType: payloadIDType,
100
105
  init: adapter
101
106
  };
102
107
  }
103
- /**
104
- * Attempt to find migrations directory.
105
- *
106
- * Checks for the following directories in order:
107
- * - `migrationDir` argument from Payload config
108
- * - `src/migrations`
109
- * - `dist/migrations`
110
- * - `migrations`
111
- *
112
- * Defaults to `src/migrations`
113
- *
114
- * @param migrationDir
115
- * @returns
116
- */ function findMigrationDir(migrationDir) {
117
- const cwd = process.cwd();
118
- const srcDir = path.resolve(cwd, 'src/migrations');
119
- const distDir = path.resolve(cwd, 'dist/migrations');
120
- const relativeMigrations = path.resolve(cwd, 'migrations');
121
- // Use arg if provided
122
- if (migrationDir) return migrationDir;
123
- // Check other common locations
124
- if (fs.existsSync(srcDir)) {
125
- return srcDir;
126
- }
127
- if (fs.existsSync(distDir)) {
128
- return distDir;
129
- }
130
- if (fs.existsSync(relativeMigrations)) {
131
- return relativeMigrations;
132
- }
133
- return srcDir;
134
- }
135
108
 
136
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 { 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 function adapter({ payload }: { payload: Payload }) {\n const migrationDir = findMigrationDir(args.migrationDir)\n const idType = args.idType || 'serial'\n\n return createDatabaseAdapter<PostgresAdapter>({\n name: 'postgres',\n\n // Postgres-specific\n blockTableNames: {},\n drizzle: undefined,\n enums: {},\n fieldConstraints: {},\n idType,\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 tables: {},\n versionsSuffix: args.versionsSuffix || '_v',\n\n // DatabaseAdapter\n beginTransaction,\n commitTransaction,\n connect,\n create,\n createGlobal,\n createGlobalVersion,\n createMigration,\n createVersion,\n /**\n * This represents how a default ID is treated in Payload as were a field type\n */\n defaultIDType: idType === 'serial' ? 'number' : 'text',\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 rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n })\n }\n\n return {\n defaultIDType: 'number',\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","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","adapter","payload","migrationDir","findMigrationDir","idType","name","blockTableNames","drizzle","undefined","enums","fieldConstraints","localesSuffix","logger","pgSchema","pool","poolOptions","push","relations","relationshipsSuffix","schema","schemaName","sessions","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,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;AAClD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,gBAAgB,QAAQ,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AiBD,YAAqB;IAC7C,MAAMuB,MAAMC,QAAQD,GAAG;IACvB,MAAME,SAAS9D,KAAK+D,OAAO,CAACH,KAAK;IACjC,MAAMI,UAAUhE,KAAK+D,OAAO,CAACH,KAAK;IAClC,MAAMK,qBAAqBjE,KAAK+D,OAAO,CAACH,KAAK;IAE7C,sBAAsB;IACtB,IAAIvB,cAAc,OAAOA;IAEzB,+BAA+B;IAC/B,IAAItC,GAAGmE,UAAU,CAACJ,SAAS;QACzB,OAAOA;IACT;IAEA,IAAI/D,GAAGmE,UAAU,CAACF,UAAU;QAC1B,OAAOA;IACT;IAEA,IAAIjE,GAAGmE,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 { createDatabaseAdapter } from 'payload'\n\nimport type { Args, PostgresAdapter } from './types.js'\n\nimport { connect } from './connect.js'\nimport { countDistinct } from './countDistinct.js'\nimport { convertPathToJSONTraversal } from './createJSONQuery/convertPathToJSONTraversal.js'\nimport { createJSONQuery } from './createJSONQuery/index.js'\nimport { createMigration } from './createMigration.js'\nimport { defaultDrizzleSnapshot } from './defaultSnapshot.js'\nimport { deleteWhere } from './deleteWhere.js'\nimport { dropDatabase } from './dropDatabase.js'\nimport { execute } from './execute.js'\nimport { getMigrationTemplate } from './getMigrationTemplate.js'\nimport { init } from './init.js'\nimport { insert } from './insert.js'\nimport { requireDrizzleKit } from './requireDrizzleKit.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 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: 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 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"],"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","createDatabaseAdapter","connect","countDistinct","convertPathToJSONTraversal","createJSONQuery","createMigration","defaultDrizzleSnapshot","deleteWhere","dropDatabase","execute","getMigrationTemplate","init","insert","requireDrizzleKit","sql","postgresAdapter","args","postgresIDType","idType","payloadIDType","adapter","payload","migrationDir","resolveInitializing","rejectInitializing","initializing","Promise","res","rej","name","drizzle","undefined","enums","features","json","fieldConstraints","localesSuffix","logger","operators","pgSchema","pool","poolOptions","push","relations","relationshipsSuffix","schema","schemaName","sessions","tableNameMap","Map","tables","transactionOptions","versionsSuffix","defaultIDType"],"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,aAAa,EACbC,WAAW,EACXC,WAAW,EACXC,mBAAmB,EACnBC,YAAY,EACZC,mBAAmB,EACnBC,SAAS,EACTC,aAAa,QACR,sBAAqB;AAC5B,SAASC,qBAAqB,QAAQ,UAAS;AAI/C,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,0BAA0B,QAAQ,kDAAiD;AAC5F,SAASC,eAAe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KoC,cAAc,IAAI;YAEvC,kBAAkB;YAClBlF,kBAAkB8C,KAAKmC,kBAAkB,KAAK,QAAQpB,YAAY7D;YAClEC;YACA8B;YACAE;YACA/B;YACA8B;YACA7B;YACAC;YACAC;YACA6B;YACAC;YACA7B;YACA6E,eAAelC;YACf1C;YACAC;YACAC;YACA4B;YACA3B;YACA4B;YACAC;YACA5B;YACAC;YACAC;YACAE;YACAC;YACAyB;YACAC;YACAzB;YACAC;YACAC;YACAC;YACAC;YACAC;YACA8B;YACAD;YACA3B;YACA8B;YACAX;YACAU;YACA5B;YACAC;YACAC;YACAC;YACAC;QACF;IACF;IAEA,OAAO;QACLsD,eAAelC;QACfR,MAAMS;IACR;AACF"}
package/dist/init.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { Init } from 'payload/database';
1
+ import type { Init } from 'payload';
2
2
  export declare const init: Init;
3
3
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAW5C,eAAO,MAAM,IAAI,EAAE,IA0FlB,CAAA"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAA6B,MAAM,SAAS,CAAA;AAW9D,eAAO,MAAM,IAAI,EAAE,IA4FlB,CAAA"}
package/dist/init.js CHANGED
@@ -1,7 +1,8 @@
1
- /* eslint-disable no-param-reassign */ import { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core';
2
- import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions';
1
+ import { createTableName } from '@payloadcms/drizzle';
2
+ import { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core';
3
+ import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload';
4
+ import toSnakeCase from 'to-snake-case';
3
5
  import { buildTable } from './schema/build.js';
4
- import { getTableName } from './schema/getTableName.js';
5
6
  export const init = function init() {
6
7
  if (this.schemaName) {
7
8
  this.pgSchema = pgSchema(this.schemaName);
@@ -14,15 +15,23 @@ export const init = function init() {
14
15
  this.enums.enum__locales = pgEnum('_locales', this.payload.config.localization.locales.map(({ code })=>code));
15
16
  }
16
17
  this.payload.config.collections.forEach((collection)=>{
17
- const tableName = getTableName({
18
+ createTableName({
18
19
  adapter: this,
19
20
  config: collection
20
21
  });
22
+ if (collection.versions) {
23
+ createTableName({
24
+ adapter: this,
25
+ config: collection,
26
+ versions: true,
27
+ versionsCustomName: true
28
+ });
29
+ }
30
+ });
31
+ this.payload.config.collections.forEach((collection)=>{
32
+ const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
21
33
  buildTable({
22
34
  adapter: this,
23
- buildNumbers: true,
24
- buildRelationships: true,
25
- buildTexts: true,
26
35
  disableNotNull: !!collection?.versions?.drafts,
27
36
  disableUnique: false,
28
37
  fields: collection.fields,
@@ -31,17 +40,10 @@ export const init = function init() {
31
40
  versions: false
32
41
  });
33
42
  if (collection.versions) {
34
- const versionsTableName = getTableName({
35
- adapter: this,
36
- config: collection,
37
- versions: true
38
- });
43
+ const versionsTableName = this.tableNameMap.get(`_${toSnakeCase(collection.slug)}${this.versionsSuffix}`);
39
44
  const versionFields = buildVersionCollectionFields(collection);
40
45
  buildTable({
41
46
  adapter: this,
42
- buildNumbers: true,
43
- buildRelationships: true,
44
- buildTexts: true,
45
47
  disableNotNull: !!collection.versions?.drafts,
46
48
  disableUnique: true,
47
49
  fields: versionFields,
@@ -52,15 +54,12 @@ export const init = function init() {
52
54
  }
53
55
  });
54
56
  this.payload.config.globals.forEach((global)=>{
55
- const tableName = getTableName({
57
+ const tableName = createTableName({
56
58
  adapter: this,
57
59
  config: global
58
60
  });
59
61
  buildTable({
60
62
  adapter: this,
61
- buildNumbers: true,
62
- buildRelationships: true,
63
- buildTexts: true,
64
63
  disableNotNull: !!global?.versions?.drafts,
65
64
  disableUnique: false,
66
65
  fields: global.fields,
@@ -69,17 +68,15 @@ export const init = function init() {
69
68
  versions: false
70
69
  });
71
70
  if (global.versions) {
72
- const versionsTableName = getTableName({
71
+ const versionsTableName = createTableName({
73
72
  adapter: this,
74
73
  config: global,
75
- versions: true
74
+ versions: true,
75
+ versionsCustomName: true
76
76
  });
77
77
  const versionFields = buildVersionGlobalFields(global);
78
78
  buildTable({
79
79
  adapter: this,
80
- buildNumbers: true,
81
- buildRelationships: true,
82
- buildTexts: true,
83
80
  disableNotNull: !!global.versions?.drafts,
84
81
  disableUnique: true,
85
82
  fields: versionFields,
package/dist/init.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/init.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Init } from 'payload/database'\nimport type { SanitizedCollectionConfig } from 'payload/types'\n\nimport { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { buildTable } from './schema/build.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const init: Init = function init(this: PostgresAdapter) {\n if (this.schemaName) {\n this.pgSchema = pgSchema(this.schemaName)\n } else {\n this.pgSchema = { table: pgTable }\n }\n\n if (this.payload.config.localization) {\n this.enums.enum__locales = pgEnum(\n '_locales',\n this.payload.config.localization.locales.map(({ code }) => code) as [string, ...string[]],\n )\n }\n\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n const tableName = getTableName({\n adapter: this,\n config: collection,\n })\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!collection?.versions?.drafts,\n disableUnique: false,\n fields: collection.fields,\n tableName,\n timestamps: collection.timestamps,\n versions: false,\n })\n\n if (collection.versions) {\n const versionsTableName = getTableName({\n adapter: this,\n config: collection,\n versions: true,\n })\n const versionFields = buildVersionCollectionFields(collection)\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!collection.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n\n this.payload.config.globals.forEach((global) => {\n const tableName = getTableName({ adapter: this, config: global })\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!global?.versions?.drafts,\n disableUnique: false,\n fields: global.fields,\n tableName,\n timestamps: false,\n versions: false,\n })\n\n if (global.versions) {\n const versionsTableName = getTableName({ adapter: this, config: global, versions: true })\n const versionFields = buildVersionGlobalFields(global)\n\n buildTable({\n adapter: this,\n buildNumbers: true,\n buildRelationships: true,\n buildTexts: true,\n disableNotNull: !!global.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n}\n"],"names":["pgEnum","pgSchema","pgTable","buildVersionCollectionFields","buildVersionGlobalFields","buildTable","getTableName","init","schemaName","table","payload","config","localization","enums","enum__locales","locales","map","code","collections","forEach","collection","tableName","adapter","buildNumbers","buildRelationships","buildTexts","disableNotNull","versions","drafts","disableUnique","fields","timestamps","versionsTableName","versionFields","globals","global"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAIpC,SAASA,MAAM,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,sBAAqB;AAC/D,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,mBAAkB;AAIzF,SAASC,UAAU,QAAQ,oBAAmB;AAC9C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,OAAa,SAASA;IACjC,IAAI,IAAI,CAACC,UAAU,EAAE;QACnB,IAAI,CAACP,QAAQ,GAAGA,SA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oBAAoB;YACpBC,YAAY;YACZC,gBAAgB,CAAC,CAACS,QAAQR,UAAUC;YACpCC,eAAe;YACfC,QAAQK,OAAOL,MAAM;YACrBT;YACAU,YAAY;YACZJ,UAAU;QACZ;QAEA,IAAIQ,OAAOR,QAAQ,EAAE;YACnB,MAAMK,oBAAoB1B,aAAa;gBAAEgB,SAAS,IAAI;gBAAEX,QAAQwB;gBAAQR,UAAU;YAAK;YACvF,MAAMM,gBAAgB7B,yBAAyB+B;YAE/C9B,WAAW;gBACTiB,SAAS,IAAI;gBACbC,cAAc;gBACdC,oBAAoB;gBACpBC,YAAY;gBACZC,gBAAgB,CAAC,CAACS,OAAOR,QAAQ,EAAEC;gBACnCC,eAAe;gBACfC,QAAQG;gBACRZ,WAAWW;gBACXD,YAAY;gBACZJ,UAAU;YACZ;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/init.ts"],"sourcesContent":["import type { Init, SanitizedCollectionConfig } from 'payload'\n\nimport { createTableName } from '@payloadcms/drizzle'\nimport { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { buildTable } from './schema/build.js'\n\nexport const init: Init = function init(this: PostgresAdapter) {\n if (this.schemaName) {\n this.pgSchema = pgSchema(this.schemaName)\n } else {\n this.pgSchema = { table: pgTable }\n }\n if (this.payload.config.localization) {\n this.enums.enum__locales = pgEnum(\n '_locales',\n this.payload.config.localization.locales.map(({ code }) => code) as [string, ...string[]],\n )\n }\n\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n createTableName({\n adapter: this,\n config: collection,\n })\n\n if (collection.versions) {\n createTableName({\n adapter: this,\n config: collection,\n versions: true,\n versionsCustomName: true,\n })\n }\n })\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n buildTable({\n adapter: this,\n disableNotNull: !!collection?.versions?.drafts,\n disableUnique: false,\n fields: collection.fields,\n tableName,\n timestamps: collection.timestamps,\n versions: false,\n })\n\n if (collection.versions) {\n const versionsTableName = this.tableNameMap.get(\n `_${toSnakeCase(collection.slug)}${this.versionsSuffix}`,\n )\n const versionFields = buildVersionCollectionFields(collection)\n\n buildTable({\n adapter: this,\n disableNotNull: !!collection.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n\n this.payload.config.globals.forEach((global) => {\n const tableName = createTableName({ adapter: this, config: global })\n\n buildTable({\n adapter: this,\n disableNotNull: !!global?.versions?.drafts,\n disableUnique: false,\n fields: global.fields,\n tableName,\n timestamps: false,\n versions: false,\n })\n\n if (global.versions) {\n const versionsTableName = createTableName({\n adapter: this,\n config: global,\n versions: true,\n versionsCustomName: true,\n })\n const versionFields = buildVersionGlobalFields(global)\n\n buildTable({\n adapter: this,\n disableNotNull: !!global.versions?.drafts,\n disableUnique: true,\n fields: versionFields,\n tableName: versionsTableName,\n timestamps: true,\n versions: true,\n })\n }\n })\n}\n"],"names":["createTableName","pgEnum","pgSchema","pgTable","buildVersionCollectionFields","buildVersionGlobalFields","toSnakeCase","buildTable","init","schemaName","table","payload","config","localization","enums","enum__locales","locales","map","code","collections","forEach","collection","adapter","versions","versionsCustomName","tableName","tableNameMap","get","slug","disableNotNull","drafts","disableUnique","fields","timestamps","versionsTableName","versionsSuffix","versionFields","globals","global"],"mappings":"AAEA,SAASA,eAAe,QAAQ,sBAAqB;AACrD,SAASC,MAAM,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,sBAAqB;AAC/D,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAChF,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,UAAU,QAAQ,oBAAmB;AAE9C,OAAO,MAAMC,OAAa,SAASA;IACjC,IAAI,IAAI,CAACC,UAAU,EAAE;QAC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;gBACfC,QAAQI;gBACRX,WAAWS;gBACXD,YAAY;gBACZV,UAAU;YACZ;QACF;IACF;IAEA,IAAI,CAACZ,OAAO,CAACC,MAAM,CAACyB,OAAO,CAACjB,OAAO,CAAC,CAACkB;QACnC,MAAMb,YAAYzB,gBAAgB;YAAEsB,SAAS,IAAI;YAAEV,QAAQ0B;QAAO;QAElE/B,WAAW;YACTe,SAAS,IAAI;YACbO,gBAAgB,CAAC,CAACS,QAAQf,UAAUO;YACpCC,eAAe;YACfC,QAAQM,OAAON,MAAM;YACrBP;YACAQ,YAAY;YACZV,UAAU;QACZ;QAEA,IAAIe,OAAOf,QAAQ,EAAE;YACnB,MAAMW,oBAAoBlC,gBAAgB;gBACxCsB,SAAS,IAAI;gBACbV,QAAQ0B;gBACRf,UAAU;gBACVC,oBAAoB;YACtB;YACA,MAAMY,gBAAgB/B,yBAAyBiC;YAE/C/B,WAAW;gBACTe,SAAS,IAAI;gBACbO,gBAAgB,CAAC,CAACS,OAAOf,QAAQ,EAAEO;gBACnCC,eAAe;gBACfC,QAAQI;gBACRX,WAAWS;gBACXD,YAAY;gBACZV,UAAU;YACZ;QACF;IACF;AACF,EAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Insert } from './types.js';
2
+ export declare const insert: Insert;
3
+ //# sourceMappingURL=insert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC,eAAO,MAAM,MAAM,EAAE,MAoBpB,CAAA"}
package/dist/insert.js ADDED
@@ -0,0 +1,12 @@
1
+ export const insert = async function insert({ db, onConflictDoUpdate, tableName, values }) {
2
+ const table = this.tables[tableName];
3
+ let result;
4
+ if (onConflictDoUpdate) {
5
+ result = await db.insert(table).values(values).onConflictDoUpdate(onConflictDoUpdate).returning();
6
+ } else {
7
+ result = await db.insert(table).values(values).returning();
8
+ }
9
+ return result;
10
+ };
11
+
12
+ //# sourceMappingURL=insert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/insert.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\n\nimport type { Insert } from './types.js'\n\nexport const insert: Insert = async function insert({\n db,\n onConflictDoUpdate,\n tableName,\n values,\n}): Promise<Record<string, unknown>[]> {\n const table = this.tables[tableName]\n let result\n\n if (onConflictDoUpdate) {\n result = await (db as TransactionPg)\n .insert(table)\n .values(values)\n .onConflictDoUpdate(onConflictDoUpdate)\n .returning()\n } else {\n result = await (db as TransactionPg).insert(table).values(values).returning()\n }\n\n return result\n}\n"],"names":["insert","db","onConflictDoUpdate","tableName","values","table","tables","result","returning"],"mappings":"AAIA,OAAO,MAAMA,SAAiB,eAAeA,OAAO,EAClDC,EAAE,EACFC,kBAAkB,EAClBC,SAAS,EACTC,MAAM,EACP;IACC,MAAMC,QAAQ,IAAI,CAACC,MAAM,CAACH,UAAU;IACpC,IAAII;IAEJ,IAAIL,oBAAoB;QACtBK,SAAS,MAAM,AAACN,GACbD,MAAM,CAACK,OACPD,MAAM,CAACA,QACPF,kBAAkB,CAACA,oBACnBM,SAAS;IACd,OAAO;QACLD,SAAS,MAAM,AAACN,GAAqBD,MAAM,CAACK,OAAOD,MAAM,CAACA,QAAQI,SAAS;IAC7E;IAEA,OAAOD;AACT,EAAC"}
@@ -0,0 +1,4 @@
1
+ declare const imports = "import { migratePostgresV2toV3 } from '@payloadcms/db-postgres/migration-utils'";
2
+ declare const upSQL = " await migratePostgresV2toV3({\n // enables logging of changes that will be made to the database\n debug: false,\n payload,\n req,\n })\n";
3
+ export { imports, upSQL };
4
+ //# sourceMappingURL=relationships-v2-v3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationships-v2-v3.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/relationships-v2-v3.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,OAAO,oFAAoF,CAAA;AACjG,QAAA,MAAM,KAAK,mLAMV,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA"}
@@ -0,0 +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"],"mappings":"AAAA,MAAMA,UAAU,CAAC,+EAA+E,CAAC;AACjG,MAAMC,QAAQ,CAAC;;;;;;AAMf,CAAC;AAED,SAASD,OAAO,EAAEC,KAAK,GAAE"}
@@ -0,0 +1,11 @@
1
+ const imports = `import { migratePostgresV2toV3 } from '@payloadcms/db-postgres/migration-utils'`;
2
+ const upSQL = ` await migratePostgresV2toV3({
3
+ // enables logging of changes that will be made to the database
4
+ debug: false,
5
+ payload,
6
+ req,
7
+ })
8
+ `;
9
+ export { imports, upSQL };
10
+
11
+ //# sourceMappingURL=relationships-v2-v3.js.map
@@ -0,0 +1,20 @@
1
+ import type { TransactionPg } from '@payloadcms/drizzle/types';
2
+ import type { Field, Payload, PayloadRequest } from 'payload';
3
+ import type { PostgresAdapter } from '../../../types.js';
4
+ import type { DocsToResave } from '../types.js';
5
+ type Args = {
6
+ adapter: PostgresAdapter;
7
+ collectionSlug?: string;
8
+ db: TransactionPg;
9
+ debug: boolean;
10
+ docsToResave: DocsToResave;
11
+ fields: Field[];
12
+ globalSlug?: string;
13
+ isVersions: boolean;
14
+ payload: Payload;
15
+ req: PayloadRequest;
16
+ tableName: string;
17
+ };
18
+ export declare const fetchAndResave: ({ adapter, collectionSlug, db, debug, docsToResave, fields, globalSlug, isVersions, payload, req, tableName, }: Args) => Promise<void>;
19
+ export {};
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,169 @@
1
+ import { upsertRow } from '@payloadcms/drizzle';
2
+ import { traverseFields } from './traverseFields.js';
3
+ export const fetchAndResave = async ({ adapter, collectionSlug, db, debug, docsToResave, fields, globalSlug, isVersions, payload, req, tableName })=>{
4
+ for (const [id, rows] of Object.entries(docsToResave)){
5
+ if (collectionSlug) {
6
+ const collectionConfig = payload.collections[collectionSlug].config;
7
+ if (collectionConfig) {
8
+ if (isVersions) {
9
+ const doc = await payload.findVersionByID({
10
+ id,
11
+ collection: collectionSlug,
12
+ depth: 0,
13
+ fallbackLocale: null,
14
+ locale: 'all',
15
+ req,
16
+ showHiddenFields: true
17
+ });
18
+ if (debug) {
19
+ payload.logger.info(`The collection "${collectionConfig.slug}" version with ID ${id} will be migrated`);
20
+ }
21
+ traverseFields({
22
+ doc,
23
+ fields,
24
+ path: '',
25
+ rows
26
+ });
27
+ try {
28
+ await upsertRow({
29
+ id: doc.id,
30
+ adapter,
31
+ data: doc,
32
+ db,
33
+ fields,
34
+ ignoreResult: true,
35
+ operation: 'update',
36
+ req,
37
+ tableName
38
+ });
39
+ } catch (err) {
40
+ payload.logger.error(`"${collectionConfig.slug}" version with ID ${doc.id} FAILED TO MIGRATE`);
41
+ throw err;
42
+ }
43
+ if (debug) {
44
+ payload.logger.info(`"${collectionConfig.slug}" version with ID ${doc.id} migrated successfully!`);
45
+ }
46
+ } else {
47
+ const doc = await payload.findByID({
48
+ id,
49
+ collection: collectionSlug,
50
+ depth: 0,
51
+ fallbackLocale: null,
52
+ locale: 'all',
53
+ req,
54
+ showHiddenFields: true
55
+ });
56
+ if (debug) {
57
+ payload.logger.info(`The collection "${collectionConfig.slug}" with ID ${doc.id} will be migrated`);
58
+ }
59
+ traverseFields({
60
+ doc,
61
+ fields,
62
+ path: '',
63
+ rows
64
+ });
65
+ try {
66
+ await upsertRow({
67
+ id: doc.id,
68
+ adapter,
69
+ data: doc,
70
+ db,
71
+ fields,
72
+ ignoreResult: true,
73
+ operation: 'update',
74
+ req,
75
+ tableName
76
+ });
77
+ } catch (err) {
78
+ payload.logger.error(`The collection "${collectionConfig.slug}" with ID ${doc.id} has FAILED TO MIGRATE`);
79
+ throw err;
80
+ }
81
+ if (debug) {
82
+ payload.logger.info(`The collection "${collectionConfig.slug}" with ID ${doc.id} has migrated successfully!`);
83
+ }
84
+ }
85
+ }
86
+ }
87
+ if (globalSlug) {
88
+ const globalConfig = payload.config.globals?.find((global)=>global.slug === globalSlug);
89
+ if (globalConfig) {
90
+ if (isVersions) {
91
+ const { docs } = await payload.findGlobalVersions({
92
+ slug: globalSlug,
93
+ depth: 0,
94
+ fallbackLocale: null,
95
+ limit: 0,
96
+ locale: 'all',
97
+ req,
98
+ showHiddenFields: true
99
+ });
100
+ if (debug) {
101
+ payload.logger.info(`${docs.length} global "${globalSlug}" versions will be migrated`);
102
+ }
103
+ for (const doc of docs){
104
+ traverseFields({
105
+ doc,
106
+ fields,
107
+ path: '',
108
+ rows
109
+ });
110
+ try {
111
+ await upsertRow({
112
+ id: doc.id,
113
+ adapter,
114
+ data: doc,
115
+ db,
116
+ fields,
117
+ ignoreResult: true,
118
+ operation: 'update',
119
+ req,
120
+ tableName
121
+ });
122
+ } catch (err) {
123
+ payload.logger.error(`"${globalSlug}" version with ID ${doc.id} FAILED TO MIGRATE`);
124
+ throw err;
125
+ }
126
+ if (debug) {
127
+ payload.logger.info(`"${globalSlug}" version with ID ${doc.id} migrated successfully!`);
128
+ }
129
+ }
130
+ } else {
131
+ const doc = await payload.findGlobal({
132
+ slug: globalSlug,
133
+ depth: 0,
134
+ fallbackLocale: null,
135
+ locale: 'all',
136
+ req,
137
+ showHiddenFields: true
138
+ });
139
+ traverseFields({
140
+ doc,
141
+ fields,
142
+ path: '',
143
+ rows
144
+ });
145
+ try {
146
+ await upsertRow({
147
+ adapter,
148
+ data: doc,
149
+ db,
150
+ fields,
151
+ ignoreResult: true,
152
+ operation: 'update',
153
+ req,
154
+ tableName
155
+ });
156
+ } catch (err) {
157
+ payload.logger.error(`The global "${globalSlug}" has FAILED TO MIGRATE`);
158
+ throw err;
159
+ }
160
+ if (debug) {
161
+ payload.logger.info(`The global "${globalSlug}" has migrated successfully!`);
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }
167
+ };
168
+
169
+ //# sourceMappingURL=index.js.map