@payloadcms/db-postgres 3.0.0-canary.ee6d727 → 3.0.0-canary.ef0a8d0

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 +4 -6
  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 +26 -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 +6 -28
  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 +7 -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 +13 -0
  35. package/dist/execute.js.map +1 -0
  36. package/dist/exports/migration-utils.js.map +1 -1
  37. package/dist/generateDrizzleJSON.d.ts +3 -0
  38. package/dist/generateDrizzleJSON.d.ts.map +1 -0
  39. package/dist/generateDrizzleJSON.js +8 -0
  40. package/dist/generateDrizzleJSON.js.map +1 -0
  41. package/dist/generateMigration.d.ts +3 -0
  42. package/dist/generateMigration.d.ts.map +1 -0
  43. package/dist/generateMigration.js +8 -0
  44. package/dist/generateMigration.js.map +1 -0
  45. package/dist/getMigrationTemplate.d.ts +3 -0
  46. package/dist/getMigrationTemplate.d.ts.map +1 -0
  47. package/dist/getMigrationTemplate.js +12 -0
  48. package/dist/getMigrationTemplate.js.map +1 -0
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +28 -63
  52. package/dist/index.js.map +1 -1
  53. package/dist/init.d.ts +1 -1
  54. package/dist/init.d.ts.map +1 -1
  55. package/dist/init.js +2 -2
  56. package/dist/init.js.map +1 -1
  57. package/dist/insert.d.ts +3 -0
  58. package/dist/insert.d.ts.map +1 -0
  59. package/dist/insert.js +13 -0
  60. package/dist/insert.js.map +1 -0
  61. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -1
  62. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +5 -5
  63. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
  64. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +5 -2
  65. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
  66. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +1 -1
  67. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -1
  68. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +1 -1
  69. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -1
  70. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -1
  71. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -1
  72. package/dist/predefinedMigrations/v2-v3/index.d.ts +2 -3
  73. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
  74. package/dist/predefinedMigrations/v2-v3/index.js +12 -6
  75. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
  76. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +5 -4
  77. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
  78. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +1 -0
  79. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
  80. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +4 -4
  81. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
  82. package/dist/predefinedMigrations/v2-v3/traverseFields.js +1 -1
  83. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
  84. package/dist/predefinedMigrations/v2-v3/types.js.map +1 -1
  85. package/dist/requireDrizzleKit.d.ts +3 -0
  86. package/dist/requireDrizzleKit.d.ts.map +1 -0
  87. package/dist/requireDrizzleKit.js +5 -0
  88. package/dist/requireDrizzleKit.js.map +1 -0
  89. package/dist/schema/build.d.ts +1 -1
  90. package/dist/schema/build.d.ts.map +1 -1
  91. package/dist/schema/build.js +2 -2
  92. package/dist/schema/build.js.map +1 -1
  93. package/dist/schema/createIndex.js.map +1 -1
  94. package/dist/schema/idToUUID.d.ts +1 -1
  95. package/dist/schema/idToUUID.d.ts.map +1 -1
  96. package/dist/schema/idToUUID.js.map +1 -1
  97. package/dist/schema/parentIDColumnMap.js.map +1 -1
  98. package/dist/schema/setColumnID.d.ts +1 -1
  99. package/dist/schema/setColumnID.d.ts.map +1 -1
  100. package/dist/schema/setColumnID.js +2 -2
  101. package/dist/schema/setColumnID.js.map +1 -1
  102. package/dist/schema/traverseFields.d.ts +1 -1
  103. package/dist/schema/traverseFields.d.ts.map +1 -1
  104. package/dist/schema/traverseFields.js +4 -6
  105. package/dist/schema/traverseFields.js.map +1 -1
  106. package/dist/types.d.ts +72 -31
  107. package/dist/types.d.ts.map +1 -1
  108. package/dist/types.js.map +1 -1
  109. package/package.json +19 -16
  110. package/dist/count.d.ts +0 -3
  111. package/dist/count.d.ts.map +0 -1
  112. package/dist/count.js +0 -41
  113. package/dist/count.js.map +0 -1
  114. package/dist/create.d.ts +0 -3
  115. package/dist/create.d.ts.map +0 -1
  116. package/dist/create.js +0 -19
  117. package/dist/create.js.map +0 -1
  118. package/dist/createGlobal.d.ts +0 -5
  119. package/dist/createGlobal.d.ts.map +0 -1
  120. package/dist/createGlobal.js +0 -19
  121. package/dist/createGlobal.js.map +0 -1
  122. package/dist/createGlobalVersion.d.ts +0 -6
  123. package/dist/createGlobalVersion.d.ts.map +0 -1
  124. package/dist/createGlobalVersion.js +0 -33
  125. package/dist/createGlobalVersion.js.map +0 -1
  126. package/dist/createVersion.d.ts +0 -5
  127. package/dist/createVersion.d.ts.map +0 -1
  128. package/dist/createVersion.js +0 -40
  129. package/dist/createVersion.js.map +0 -1
  130. package/dist/deleteMany.d.ts +0 -3
  131. package/dist/deleteMany.d.ts.map +0 -1
  132. package/dist/deleteMany.js +0 -28
  133. package/dist/deleteMany.js.map +0 -1
  134. package/dist/deleteOne.d.ts +0 -3
  135. package/dist/deleteOne.d.ts.map +0 -1
  136. package/dist/deleteOne.js +0 -59
  137. package/dist/deleteOne.js.map +0 -1
  138. package/dist/deleteVersions.d.ts +0 -3
  139. package/dist/deleteVersions.d.ts.map +0 -1
  140. package/dist/deleteVersions.js +0 -31
  141. package/dist/deleteVersions.js.map +0 -1
  142. package/dist/destroy.d.ts +0 -3
  143. package/dist/destroy.d.ts.map +0 -1
  144. package/dist/destroy.js +0 -15
  145. package/dist/destroy.js.map +0 -1
  146. package/dist/find/buildFindManyArgs.d.ts +0 -17
  147. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  148. package/dist/find/buildFindManyArgs.js +0 -65
  149. package/dist/find/buildFindManyArgs.js.map +0 -1
  150. package/dist/find/chainMethods.d.ts +0 -16
  151. package/dist/find/chainMethods.d.ts.map +0 -1
  152. package/dist/find/chainMethods.js +0 -12
  153. package/dist/find/chainMethods.js.map +0 -1
  154. package/dist/find/findMany.d.ts +0 -22
  155. package/dist/find/findMany.d.ts.map +0 -1
  156. package/dist/find/findMany.js +0 -152
  157. package/dist/find/findMany.js.map +0 -1
  158. package/dist/find/traverseFields.d.ts +0 -17
  159. package/dist/find/traverseFields.d.ts.map +0 -1
  160. package/dist/find/traverseFields.js +0 -156
  161. package/dist/find/traverseFields.js.map +0 -1
  162. package/dist/find.d.ts +0 -3
  163. package/dist/find.d.ts.map +0 -1
  164. package/dist/find.js +0 -21
  165. package/dist/find.js.map +0 -1
  166. package/dist/findGlobal.d.ts +0 -3
  167. package/dist/findGlobal.d.ts.map +0 -1
  168. package/dist/findGlobal.js +0 -23
  169. package/dist/findGlobal.js.map +0 -1
  170. package/dist/findGlobalVersions.d.ts +0 -3
  171. package/dist/findGlobalVersions.d.ts.map +0 -1
  172. package/dist/findGlobalVersions.js +0 -24
  173. package/dist/findGlobalVersions.js.map +0 -1
  174. package/dist/findOne.d.ts +0 -5
  175. package/dist/findOne.d.ts.map +0 -1
  176. package/dist/findOne.js +0 -21
  177. package/dist/findOne.js.map +0 -1
  178. package/dist/findVersions.d.ts +0 -3
  179. package/dist/findVersions.d.ts.map +0 -1
  180. package/dist/findVersions.js +0 -24
  181. package/dist/findVersions.js.map +0 -1
  182. package/dist/migrate.d.ts +0 -3
  183. package/dist/migrate.d.ts.map +0 -1
  184. package/dist/migrate.js +0 -99
  185. package/dist/migrate.js.map +0 -1
  186. package/dist/migrateDown.d.ts +0 -3
  187. package/dist/migrateDown.d.ts.map +0 -1
  188. package/dist/migrateDown.js +0 -63
  189. package/dist/migrateDown.js.map +0 -1
  190. package/dist/migrateFresh.d.ts +0 -8
  191. package/dist/migrateFresh.d.ts.map +0 -1
  192. package/dist/migrateFresh.js +0 -72
  193. package/dist/migrateFresh.js.map +0 -1
  194. package/dist/migrateRefresh.d.ts +0 -6
  195. package/dist/migrateRefresh.d.ts.map +0 -1
  196. package/dist/migrateRefresh.js +0 -102
  197. package/dist/migrateRefresh.js.map +0 -1
  198. package/dist/migrateReset.d.ts +0 -6
  199. package/dist/migrateReset.d.ts.map +0 -1
  200. package/dist/migrateReset.js +0 -82
  201. package/dist/migrateReset.js.map +0 -1
  202. package/dist/migrateStatus.d.ts +0 -3
  203. package/dist/migrateStatus.d.ts.map +0 -1
  204. package/dist/migrateStatus.js +0 -44
  205. package/dist/migrateStatus.js.map +0 -1
  206. package/dist/queries/buildAndOrConditions.d.ts +0 -16
  207. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  208. package/dist/queries/buildAndOrConditions.js +0 -28
  209. package/dist/queries/buildAndOrConditions.js.map +0 -1
  210. package/dist/queries/buildQuery.d.ts +0 -30
  211. package/dist/queries/buildQuery.d.ts.map +0 -1
  212. package/dist/queries/buildQuery.js +0 -72
  213. package/dist/queries/buildQuery.js.map +0 -1
  214. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  215. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  216. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  217. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  218. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  219. package/dist/queries/createJSONQuery/index.js.map +0 -1
  220. package/dist/queries/getTableColumnFromPath.d.ts +0 -50
  221. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  222. package/dist/queries/getTableColumnFromPath.js +0 -517
  223. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  224. package/dist/queries/operatorMap.d.ts +0 -18
  225. package/dist/queries/operatorMap.d.ts.map +0 -1
  226. package/dist/queries/operatorMap.js +0 -24
  227. package/dist/queries/operatorMap.js.map +0 -1
  228. package/dist/queries/parseParams.d.ts +0 -16
  229. package/dist/queries/parseParams.d.ts.map +0 -1
  230. package/dist/queries/parseParams.js +0 -183
  231. package/dist/queries/parseParams.js.map +0 -1
  232. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  233. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  234. package/dist/queries/sanitizeQueryValue.js +0 -90
  235. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  236. package/dist/queries/selectDistinct.d.ts +0 -22
  237. package/dist/queries/selectDistinct.d.ts.map +0 -1
  238. package/dist/queries/selectDistinct.js +0 -30
  239. package/dist/queries/selectDistinct.js.map +0 -1
  240. package/dist/queryDrafts.d.ts +0 -3
  241. package/dist/queryDrafts.d.ts.map +0 -1
  242. package/dist/queryDrafts.js +0 -41
  243. package/dist/queryDrafts.js.map +0 -1
  244. package/dist/schema/createTableName.d.ts +0 -30
  245. package/dist/schema/createTableName.d.ts.map +0 -1
  246. package/dist/schema/createTableName.js +0 -31
  247. package/dist/schema/createTableName.js.map +0 -1
  248. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
  249. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  250. package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
  251. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  252. package/dist/transactions/beginTransaction.d.ts +0 -3
  253. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  254. package/dist/transactions/beginTransaction.js +0 -51
  255. package/dist/transactions/beginTransaction.js.map +0 -1
  256. package/dist/transactions/commitTransaction.d.ts +0 -3
  257. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  258. package/dist/transactions/commitTransaction.js +0 -14
  259. package/dist/transactions/commitTransaction.js.map +0 -1
  260. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  261. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  262. package/dist/transactions/rollbackTransaction.js +0 -13
  263. package/dist/transactions/rollbackTransaction.js.map +0 -1
  264. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  265. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  266. package/dist/transform/read/hasManyNumber.js +0 -10
  267. package/dist/transform/read/hasManyNumber.js.map +0 -1
  268. package/dist/transform/read/hasManyText.d.ts +0 -10
  269. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  270. package/dist/transform/read/hasManyText.js +0 -10
  271. package/dist/transform/read/hasManyText.js.map +0 -1
  272. package/dist/transform/read/index.d.ts +0 -14
  273. package/dist/transform/read/index.d.ts.map +0 -1
  274. package/dist/transform/read/index.js +0 -44
  275. package/dist/transform/read/index.js.map +0 -1
  276. package/dist/transform/read/relationship.d.ts +0 -10
  277. package/dist/transform/read/relationship.d.ts.map +0 -1
  278. package/dist/transform/read/relationship.js +0 -60
  279. package/dist/transform/read/relationship.js.map +0 -1
  280. package/dist/transform/read/traverseFields.d.ts +0 -57
  281. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  282. package/dist/transform/read/traverseFields.js +0 -435
  283. package/dist/transform/read/traverseFields.js.map +0 -1
  284. package/dist/transform/write/array.d.ts +0 -26
  285. package/dist/transform/write/array.d.ts.map +0 -1
  286. package/dist/transform/write/array.js +0 -58
  287. package/dist/transform/write/array.js.map +0 -1
  288. package/dist/transform/write/blocks.d.ts +0 -25
  289. package/dist/transform/write/blocks.d.ts.map +0 -1
  290. package/dist/transform/write/blocks.js +0 -54
  291. package/dist/transform/write/blocks.js.map +0 -1
  292. package/dist/transform/write/index.d.ts +0 -13
  293. package/dist/transform/write/index.d.ts.map +0 -1
  294. package/dist/transform/write/index.js +0 -41
  295. package/dist/transform/write/index.js.map +0 -1
  296. package/dist/transform/write/numbers.d.ts +0 -8
  297. package/dist/transform/write/numbers.d.ts.map +0 -1
  298. package/dist/transform/write/numbers.js +0 -11
  299. package/dist/transform/write/numbers.js.map +0 -1
  300. package/dist/transform/write/relationships.d.ts +0 -10
  301. package/dist/transform/write/relationships.d.ts.map +0 -1
  302. package/dist/transform/write/relationships.js +0 -23
  303. package/dist/transform/write/relationships.js.map +0 -1
  304. package/dist/transform/write/selects.d.ts +0 -8
  305. package/dist/transform/write/selects.d.ts.map +0 -1
  306. package/dist/transform/write/selects.js +0 -20
  307. package/dist/transform/write/selects.js.map +0 -1
  308. package/dist/transform/write/texts.d.ts +0 -8
  309. package/dist/transform/write/texts.d.ts.map +0 -1
  310. package/dist/transform/write/texts.js +0 -11
  311. package/dist/transform/write/texts.js.map +0 -1
  312. package/dist/transform/write/traverseFields.d.ts +0 -50
  313. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  314. package/dist/transform/write/traverseFields.js +0 -445
  315. package/dist/transform/write/traverseFields.js.map +0 -1
  316. package/dist/transform/write/types.d.ts +0 -43
  317. package/dist/transform/write/types.d.ts.map +0 -1
  318. package/dist/transform/write/types.js +0 -3
  319. package/dist/transform/write/types.js.map +0 -1
  320. package/dist/update.d.ts +0 -3
  321. package/dist/update.d.ts.map +0 -1
  322. package/dist/update.js +0 -54
  323. package/dist/update.js.map +0 -1
  324. package/dist/updateGlobal.d.ts +0 -5
  325. package/dist/updateGlobal.d.ts.map +0 -1
  326. package/dist/updateGlobal.js +0 -25
  327. package/dist/updateGlobal.js.map +0 -1
  328. package/dist/updateGlobalVersion.d.ts +0 -5
  329. package/dist/updateGlobalVersion.d.ts.map +0 -1
  330. package/dist/updateGlobalVersion.js +0 -36
  331. package/dist/updateGlobalVersion.js.map +0 -1
  332. package/dist/updateVersion.d.ts +0 -5
  333. package/dist/updateVersion.d.ts.map +0 -1
  334. package/dist/updateVersion.js +0 -36
  335. package/dist/updateVersion.js.map +0 -1
  336. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  337. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  338. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  339. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  340. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  341. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  342. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  343. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  344. package/dist/upsertRow/index.d.ts +0 -4
  345. package/dist/upsertRow/index.d.ts.map +0 -1
  346. package/dist/upsertRow/index.js +0 -279
  347. package/dist/upsertRow/index.js.map +0 -1
  348. package/dist/upsertRow/insertArrays.d.ts +0 -13
  349. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  350. package/dist/upsertRow/insertArrays.js +0 -68
  351. package/dist/upsertRow/insertArrays.js.map +0 -1
  352. package/dist/upsertRow/types.d.ts +0 -32
  353. package/dist/upsertRow/types.d.ts.map +0 -1
  354. package/dist/upsertRow/types.js +0 -3
  355. package/dist/upsertRow/types.js.map +0 -1
  356. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  357. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  358. package/dist/utilities/appendPrefixToKeys.js +0 -6
  359. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  360. package/dist/utilities/createBlocksMap.d.ts +0 -5
  361. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  362. package/dist/utilities/createBlocksMap.js +0 -29
  363. package/dist/utilities/createBlocksMap.js.map +0 -1
  364. package/dist/utilities/createMigrationTable.d.ts +0 -3
  365. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  366. package/dist/utilities/createMigrationTable.js +0 -13
  367. package/dist/utilities/createMigrationTable.js.map +0 -1
  368. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  369. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  370. package/dist/utilities/createRelationshipMap.js +0 -19
  371. package/dist/utilities/createRelationshipMap.js.map +0 -1
  372. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  373. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  374. package/dist/utilities/hasLocalesTable.js +0 -11
  375. package/dist/utilities/hasLocalesTable.js.map +0 -1
  376. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  377. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  378. package/dist/utilities/isArrayOfRows.js +0 -5
  379. package/dist/utilities/isArrayOfRows.js.map +0 -1
  380. package/dist/utilities/migrationTableExists.d.ts +0 -3
  381. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  382. package/dist/utilities/migrationTableExists.js +0 -9
  383. package/dist/utilities/migrationTableExists.js.map +0 -1
  384. package/dist/utilities/parseError.d.ts +0 -5
  385. package/dist/utilities/parseError.d.ts.map +0 -1
  386. package/dist/utilities/parseError.js +0 -17
  387. package/dist/utilities/parseError.js.map +0 -1
  388. package/dist/utilities/pushDevSchema.d.ts +0 -9
  389. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  390. package/dist/utilities/pushDevSchema.js +0 -58
  391. package/dist/utilities/pushDevSchema.js.map +0 -1
  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
@@ -1,7 +1,7 @@
1
1
  import { sql } from 'drizzle-orm';
2
2
  import fs from 'fs';
3
3
  import { createRequire } from 'module';
4
- import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions';
4
+ import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload';
5
5
  import toSnakeCase from 'to-snake-case';
6
6
  import { groupUpSQLStatements } from './groupUpSQLStatements.js';
7
7
  import { migrateRelationships } from './migrateRelationships.js';
@@ -22,17 +22,17 @@ const require = createRequire(import.meta.url);
22
22
  * @param req
23
23
  */ export const migratePostgresV2toV3 = async ({ debug, payload, req })=>{
24
24
  const adapter = payload.db;
25
- const db = adapter.sessions[req.transactionID]?.db;
25
+ const db = adapter.sessions[await req.transactionID].db;
26
26
  const dir = payload.db.migrationDir;
27
27
  // get the drizzle migrateUpSQL from drizzle using the last schema
28
28
  const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload');
29
29
  const drizzleJsonAfter = generateDrizzleJson(adapter.schema);
30
- // Get latest migration snapshot
31
- const latestSnapshot = fs.readdirSync(dir).filter((file)=>file.endsWith('.json')).sort().reverse()?.[0];
32
- if (!latestSnapshot) {
30
+ // Get the previous migration snapshot
31
+ const previousSnapshot = fs.readdirSync(dir).filter((file)=>file.endsWith('.json') && !file.endsWith('relationships_v2_v3.json')).sort().reverse()?.[0];
32
+ if (!previousSnapshot) {
33
33
  throw new Error(`No previous migration schema file found! A prior migration from v2 is required to migrate to v3.`);
34
34
  }
35
- const drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'));
35
+ const drizzleJsonBefore = JSON.parse(fs.readFileSync(`${dir}/${previousSnapshot}`, 'utf8'));
36
36
  const generatedSQL = await generateMigration(drizzleJsonBefore, drizzleJsonAfter);
37
37
  if (!generatedSQL.length) {
38
38
  payload.logger.info(`No schema changes needed.`);
@@ -44,6 +44,7 @@ const require = createRequire(import.meta.url);
44
44
  payload.logger.info('CREATING NEW RELATIONSHIP COLUMNS');
45
45
  payload.logger.info(addColumnsStatement);
46
46
  }
47
+ // @ts-expect-error drizzle-orm confusing libsql and pgsql types
47
48
  await db.execute(sql.raw(addColumnsStatement));
48
49
  for (const collection of payload.config.collections){
49
50
  const tableName = adapter.tableNameMap.get(toSnakeCase(collection.slug));
@@ -177,6 +178,7 @@ const require = createRequire(import.meta.url);
177
178
  payload.logger.info('ADDING CONSTRAINTS');
178
179
  payload.logger.info(addConstraintsStatement);
179
180
  }
181
+ // @ts-expect-error drizzle-orm confusing libsql and pgsql types
180
182
  await db.execute(sql.raw(addConstraintsStatement));
181
183
  // NOT NULL
182
184
  const notNullStatements = sqlUpStatements.notNull.join('\n');
@@ -184,6 +186,7 @@ const require = createRequire(import.meta.url);
184
186
  payload.logger.info('NOT NULL CONSTRAINTS');
185
187
  payload.logger.info(notNullStatements);
186
188
  }
189
+ // @ts-expect-error drizzle-orm confusing libsql and pgsql types
187
190
  await db.execute(sql.raw(notNullStatements));
188
191
  // DROP TABLE
189
192
  const dropTablesStatement = sqlUpStatements.dropTable.join('\n');
@@ -191,6 +194,7 @@ const require = createRequire(import.meta.url);
191
194
  payload.logger.info('DROPPING TABLES');
192
195
  payload.logger.info(dropTablesStatement);
193
196
  }
197
+ // @ts-expect-error drizzle-orm confusing libsql and pgsql types
194
198
  await db.execute(sql.raw(dropTablesStatement));
195
199
  // DROP CONSTRAINT
196
200
  const dropConstraintsStatement = sqlUpStatements.dropConstraint.join('\n');
@@ -198,6 +202,7 @@ const require = createRequire(import.meta.url);
198
202
  payload.logger.info('DROPPING CONSTRAINTS');
199
203
  payload.logger.info(dropConstraintsStatement);
200
204
  }
205
+ // @ts-expect-error drizzle-orm confusing libsql and pgsql types
201
206
  await db.execute(sql.raw(dropConstraintsStatement));
202
207
  // DROP COLUMN
203
208
  const dropColumnsStatement = sqlUpStatements.dropColumn.join('\n');
@@ -205,6 +210,7 @@ const require = createRequire(import.meta.url);
205
210
  payload.logger.info('DROPPING COLUMNS');
206
211
  payload.logger.info(dropColumnsStatement);
207
212
  }
213
+ // @ts-expect-error drizzle-orm confusing libsql and pgsql types
208
214
  await db.execute(sql.raw(dropColumnsStatement));
209
215
  };
210
216
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/index.ts"],"sourcesContent":["import type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\nimport type { Payload } from 'payload'\nimport type { PayloadRequestWithData } from 'payload/types'\n\nimport { sql } from 'drizzle-orm'\nimport fs from 'fs'\nimport { createRequire } from 'module'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { PathsToQuery } from './types.js'\n\nimport { groupUpSQLStatements } from './groupUpSQLStatements.js'\nimport { migrateRelationships } from './migrateRelationships.js'\nimport { traverseFields } from './traverseFields.js'\n\nconst require = createRequire(import.meta.url)\n\ntype Args = {\n debug?: boolean\n payload: Payload\n req?: Partial<PayloadRequestWithData>\n}\n\n/**\n * Moves upload and relationship columns from the join table and into the tables while moving data\n * This is done in the following order:\n * ADD COLUMNs\n * -- manipulate data to move relationships to new columns\n * ADD CONSTRAINTs\n * NOT NULLs\n * DROP TABLEs\n * DROP CONSTRAINTs\n * DROP COLUMNs\n * @param debug\n * @param payload\n * @param req\n */\nexport const migratePostgresV2toV3 = async ({ debug, payload, req }: Args) => {\n const adapter = payload.db as PostgresAdapter\n const db = adapter.sessions[req.transactionID]?.db\n const dir = payload.db.migrationDir\n\n // get the drizzle migrateUpSQL from drizzle using the last schema\n const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload')\n const drizzleJsonAfter = generateDrizzleJson(adapter.schema)\n\n // Get latest migration snapshot\n const latestSnapshot = fs\n .readdirSync(dir)\n .filter((file) => file.endsWith('.json'))\n .sort()\n .reverse()?.[0]\n\n if (!latestSnapshot) {\n throw new Error(\n `No previous migration schema file found! A prior migration from v2 is required to migrate to v3.`,\n )\n }\n\n const drizzleJsonBefore = JSON.parse(\n fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'),\n ) as DrizzleSnapshotJSON\n\n const generatedSQL = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n\n if (!generatedSQL.length) {\n payload.logger.info(`No schema changes needed.`)\n process.exit(0)\n }\n\n const sqlUpStatements = groupUpSQLStatements(generatedSQL)\n\n const addColumnsStatement = sqlUpStatements.addColumn.join('\\n')\n\n if (debug) {\n payload.logger.info('CREATING NEW RELATIONSHIP COLUMNS')\n payload.logger.info(addColumnsStatement)\n }\n\n await db.execute(sql.raw(addColumnsStatement))\n\n for (const collection of payload.config.collections) {\n const tableName = adapter.tableNameMap.get(toSnakeCase(collection.slug))\n const pathsToQuery: PathsToQuery = new Set()\n\n traverseFields({\n adapter,\n collectionSlug: collection.slug,\n columnPrefix: '',\n db,\n disableNotNull: false,\n fields: collection.fields,\n isVersions: false,\n newTableName: tableName,\n parentTableName: tableName,\n path: '',\n pathsToQuery,\n payload,\n rootTableName: tableName,\n })\n\n await migrateRelationships({\n adapter,\n collectionSlug: collection.slug,\n db,\n debug,\n fields: collection.fields,\n isVersions: false,\n pathsToQuery,\n payload,\n req,\n tableName,\n })\n\n if (collection.versions) {\n const versionsTableName = adapter.tableNameMap.get(\n `_${toSnakeCase(collection.slug)}${adapter.versionsSuffix}`,\n )\n const versionFields = buildVersionCollectionFields(collection)\n const versionPathsToQuery: PathsToQuery = new Set()\n\n traverseFields({\n adapter,\n collectionSlug: collection.slug,\n columnPrefix: '',\n db,\n disableNotNull: true,\n fields: versionFields,\n isVersions: true,\n newTableName: versionsTableName,\n parentTableName: versionsTableName,\n path: '',\n pathsToQuery: versionPathsToQuery,\n payload,\n rootTableName: versionsTableName,\n })\n\n await migrateRelationships({\n adapter,\n collectionSlug: collection.slug,\n db,\n debug,\n fields: versionFields,\n isVersions: true,\n pathsToQuery: versionPathsToQuery,\n payload,\n req,\n tableName: versionsTableName,\n })\n }\n }\n\n for (const global of payload.config.globals) {\n const tableName = adapter.tableNameMap.get(toSnakeCase(global.slug))\n\n const pathsToQuery: PathsToQuery = new Set()\n\n traverseFields({\n adapter,\n columnPrefix: '',\n db,\n disableNotNull: false,\n fields: global.fields,\n globalSlug: global.slug,\n isVersions: false,\n newTableName: tableName,\n parentTableName: tableName,\n path: '',\n pathsToQuery,\n payload,\n rootTableName: tableName,\n })\n\n await migrateRelationships({\n adapter,\n db,\n debug,\n fields: global.fields,\n globalSlug: global.slug,\n isVersions: false,\n pathsToQuery,\n payload,\n req,\n tableName,\n })\n\n if (global.versions) {\n const versionsTableName = adapter.tableNameMap.get(\n `_${toSnakeCase(global.slug)}${adapter.versionsSuffix}`,\n )\n\n const versionFields = buildVersionGlobalFields(global)\n\n const versionPathsToQuery: PathsToQuery = new Set()\n\n traverseFields({\n adapter,\n columnPrefix: '',\n db,\n disableNotNull: true,\n fields: versionFields,\n globalSlug: global.slug,\n isVersions: true,\n newTableName: versionsTableName,\n parentTableName: versionsTableName,\n path: '',\n pathsToQuery: versionPathsToQuery,\n payload,\n rootTableName: versionsTableName,\n })\n\n await migrateRelationships({\n adapter,\n db,\n debug,\n fields: versionFields,\n globalSlug: global.slug,\n isVersions: true,\n pathsToQuery: versionPathsToQuery,\n payload,\n req,\n tableName: versionsTableName,\n })\n }\n }\n\n // ADD CONSTRAINT\n const addConstraintsStatement = sqlUpStatements.addConstraint.join('\\n')\n\n if (debug) {\n payload.logger.info('ADDING CONSTRAINTS')\n payload.logger.info(addConstraintsStatement)\n }\n\n await db.execute(sql.raw(addConstraintsStatement))\n\n // NOT NULL\n const notNullStatements = sqlUpStatements.notNull.join('\\n')\n\n if (debug) {\n payload.logger.info('NOT NULL CONSTRAINTS')\n payload.logger.info(notNullStatements)\n }\n\n await db.execute(sql.raw(notNullStatements))\n\n // DROP TABLE\n const dropTablesStatement = sqlUpStatements.dropTable.join('\\n')\n\n if (debug) {\n payload.logger.info('DROPPING TABLES')\n payload.logger.info(dropTablesStatement)\n }\n\n await db.execute(sql.raw(dropTablesStatement))\n\n // DROP CONSTRAINT\n const dropConstraintsStatement = sqlUpStatements.dropConstraint.join('\\n')\n\n if (debug) {\n payload.logger.info('DROPPING CONSTRAINTS')\n payload.logger.info(dropConstraintsStatement)\n }\n\n await db.execute(sql.raw(dropConstraintsStatement))\n\n // DROP COLUMN\n const dropColumnsStatement = sqlUpStatements.dropColumn.join('\\n')\n\n if (debug) {\n payload.logger.info('DROPPING COLUMNS')\n payload.logger.info(dropColumnsStatement)\n }\n\n await db.execute(sql.raw(dropColumnsStatement))\n}\n"],"names":["sql","fs","createRequire","buildVersionCollectionFields","buildVersionGlobalFields","toSnakeCase","groupUpSQLStatements","migrateRelationships","traverseFields","require","url","migratePostgresV2toV3","debug","payload","req","adapter","db","sessions","transactionID","dir","migrationDir","generateDrizzleJson","generateMigration","drizzleJsonAfter","schema","latestSnapshot","readdirSync","filter","file","endsWith","sort","reverse","Error","drizzleJsonBefore","JSON","parse","readFileSync","generatedSQL","length","logger","info","process","exit","sqlUpStatements","addColumnsStatement","addColumn","join","execute","raw","collection","config","collections","tableName","tableNameMap","get","slug","pathsToQuery","Set","collectionSlug","columnPrefix","disableNotNull","fields","isVersions","newTableName","parentTableName","path","rootTableName","versions","versionsTableName","versionsSuffix","versionFields","versionPathsToQuery","global","globals","globalSlug","addConstraintsStatement","addConstraint","notNullStatements","notNull","dropTablesStatement","dropTable","dropConstraintsStatement","dropConstraint","dropColumnsStatement","dropColumn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,GAAG,QAAQ,cAAa;AACjC,OAAOC,QAAQ,KAAI;AACnB,SAASC,aAAa,QAAQ,SAAQ;AACtC,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,mBAAkB;AACzF,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AAEpD,MAAMC,UAAUP,cAAc,YAAYQ,GAAG;AAQ7C;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,wBAAwB,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAEC,GAAG,EAAQ;IACvE,MAAMC,UAAUF,QAAQG,E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AAC;QACpB3B,QAAQ0B,MAAM,CAACC,IAAI,CAACqC;IACtB;IAEA,MAAM7D,GAAG+B,OAAO,CAAC/C,IAAIgD,GAAG,CAAC6B;IAEzB,aAAa;IACb,MAAME,sBAAsBpC,gBAAgBqC,SAAS,CAAClC,IAAI,CAAC;IAE3D,IAAIlC,OAAO;QACTC,QAAQ0B,MAAM,CAACC,IAAI,CAAC;QACpB3B,QAAQ0B,MAAM,CAACC,IAAI,CAACuC;IACtB;IAEA,MAAM/D,GAAG+B,OAAO,CAAC/C,IAAIgD,GAAG,CAAC+B;IAEzB,kBAAkB;IAClB,MAAME,2BAA2BtC,gBAAgBuC,cAAc,CAACpC,IAAI,CAAC;IAErE,IAAIlC,OAAO;QACTC,QAAQ0B,MAAM,CAACC,IAAI,CAAC;QACpB3B,QAAQ0B,MAAM,CAACC,IAAI,CAACyC;IACtB;IAEA,MAAMjE,GAAG+B,OAAO,CAAC/C,IAAIgD,GAAG,CAACiC;IAEzB,cAAc;IACd,MAAME,uBAAuBxC,gBAAgByC,UAAU,CAACtC,IAAI,CAAC;IAE7D,IAAIlC,OAAO;QACTC,QAAQ0B,MAAM,CAACC,IAAI,CAAC;QACpB3B,QAAQ0B,MAAM,CAACC,IAAI,CAAC2C;IACtB;IAEA,MAAMnE,GAAG+B,OAAO,CAAC/C,IAAIgD,GAAG,CAACmC;AAC3B,EAAC"}
1
+ {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/index.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\nimport type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\nimport type { Payload, PayloadRequest } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport fs from 'fs'\nimport { createRequire } from 'module'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { PathsToQuery } from './types.js'\n\nimport { groupUpSQLStatements } from './groupUpSQLStatements.js'\nimport { migrateRelationships } from './migrateRelationships.js'\nimport { traverseFields } from './traverseFields.js'\n\nconst require = createRequire(import.meta.url)\n\ntype Args = {\n debug?: boolean\n payload: Payload\n req?: Partial<PayloadRequest>\n}\n\n/**\n * Moves upload and relationship columns from the join table and into the tables while moving data\n * This is done in the following order:\n * ADD COLUMNs\n * -- manipulate data to move relationships to new columns\n * ADD CONSTRAINTs\n * NOT NULLs\n * DROP TABLEs\n * DROP CONSTRAINTs\n * DROP COLUMNs\n * @param debug\n * @param payload\n * @param req\n */\nexport const migratePostgresV2toV3 = async ({ debug, payload, req }: Args) => {\n const adapter = payload.db as unknown as PostgresAdapter\n const db = adapter.sessions[await req.transactionID].db as TransactionPg\n const dir = payload.db.migrationDir\n\n // get the drizzle migrateUpSQL from drizzle using the last schema\n const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload')\n const drizzleJsonAfter = generateDrizzleJson(adapter.schema)\n\n // Get the previous migration snapshot\n const previousSnapshot = fs\n .readdirSync(dir)\n .filter((file) => file.endsWith('.json') && !file.endsWith('relationships_v2_v3.json'))\n .sort()\n .reverse()?.[0]\n\n if (!previousSnapshot) {\n throw new Error(\n `No previous migration schema file found! A prior migration from v2 is required to migrate to v3.`,\n )\n }\n\n const drizzleJsonBefore = JSON.parse(\n fs.readFileSync(`${dir}/${previousSnapshot}`, 'utf8'),\n ) as DrizzleSnapshotJSON\n\n const generatedSQL = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n\n if (!generatedSQL.length) {\n payload.logger.info(`No schema changes needed.`)\n process.exit(0)\n }\n\n const sqlUpStatements = groupUpSQLStatements(generatedSQL)\n\n const addColumnsStatement = sqlUpStatements.addColumn.join('\\n')\n\n if (debug) {\n payload.logger.info('CREATING NEW RELATIONSHIP COLUMNS')\n payload.logger.info(addColumnsStatement)\n }\n\n // @ts-expect-error drizzle-orm confusing libsql and pgsql types\n await db.execute(sql.raw(addColumnsStatement))\n\n for (const collection of payload.config.collections) {\n const tableName = adapter.tableNameMap.get(toSnakeCase(collection.slug))\n const pathsToQuery: PathsToQuery = new Set()\n\n traverseFields({\n adapter,\n collectionSlug: collection.slug,\n columnPrefix: '',\n db,\n disableNotNull: false,\n fields: collection.fields,\n isVersions: false,\n newTableName: tableName,\n parentTableName: tableName,\n path: '',\n pathsToQuery,\n payload,\n rootTableName: tableName,\n })\n\n await migrateRelationships({\n adapter,\n collectionSlug: collection.slug,\n db,\n debug,\n fields: collection.fields,\n isVersions: false,\n pathsToQuery,\n payload,\n req,\n tableName,\n })\n\n if (collection.versions) {\n const versionsTableName = adapter.tableNameMap.get(\n `_${toSnakeCase(collection.slug)}${adapter.versionsSuffix}`,\n )\n const versionFields = buildVersionCollectionFields(collection)\n const versionPathsToQuery: PathsToQuery = new Set()\n\n traverseFields({\n adapter,\n collectionSlug: collection.slug,\n columnPrefix: '',\n db,\n disableNotNull: true,\n fields: versionFields,\n isVersions: true,\n newTableName: versionsTableName,\n parentTableName: versionsTableName,\n path: '',\n pathsToQuery: versionPathsToQuery,\n payload,\n rootTableName: versionsTableName,\n })\n\n await migrateRelationships({\n adapter,\n collectionSlug: collection.slug,\n db,\n debug,\n fields: versionFields,\n isVersions: true,\n pathsToQuery: versionPathsToQuery,\n payload,\n req,\n tableName: versionsTableName,\n })\n }\n }\n\n for (const global of payload.config.globals) {\n const tableName = adapter.tableNameMap.get(toSnakeCase(global.slug))\n\n const pathsToQuery: PathsToQuery = new Set()\n\n traverseFields({\n adapter,\n columnPrefix: '',\n db,\n disableNotNull: false,\n fields: global.fields,\n globalSlug: global.slug,\n isVersions: false,\n newTableName: tableName,\n parentTableName: tableName,\n path: '',\n pathsToQuery,\n payload,\n rootTableName: tableName,\n })\n\n await migrateRelationships({\n adapter,\n db,\n debug,\n fields: global.fields,\n globalSlug: global.slug,\n isVersions: false,\n pathsToQuery,\n payload,\n req,\n tableName,\n })\n\n if (global.versions) {\n const versionsTableName = adapter.tableNameMap.get(\n `_${toSnakeCase(global.slug)}${adapter.versionsSuffix}`,\n )\n\n const versionFields = buildVersionGlobalFields(global)\n\n const versionPathsToQuery: PathsToQuery = new Set()\n\n traverseFields({\n adapter,\n columnPrefix: '',\n db,\n disableNotNull: true,\n fields: versionFields,\n globalSlug: global.slug,\n isVersions: true,\n newTableName: versionsTableName,\n parentTableName: versionsTableName,\n path: '',\n pathsToQuery: versionPathsToQuery,\n payload,\n rootTableName: versionsTableName,\n })\n\n await migrateRelationships({\n adapter,\n db,\n debug,\n fields: versionFields,\n globalSlug: global.slug,\n isVersions: true,\n pathsToQuery: versionPathsToQuery,\n payload,\n req,\n tableName: versionsTableName,\n })\n }\n }\n\n // ADD CONSTRAINT\n const addConstraintsStatement = sqlUpStatements.addConstraint.join('\\n')\n\n if (debug) {\n payload.logger.info('ADDING CONSTRAINTS')\n payload.logger.info(addConstraintsStatement)\n }\n\n // @ts-expect-error drizzle-orm confusing libsql and pgsql types\n await db.execute(sql.raw(addConstraintsStatement))\n\n // NOT NULL\n const notNullStatements = sqlUpStatements.notNull.join('\\n')\n\n if (debug) {\n payload.logger.info('NOT NULL CONSTRAINTS')\n payload.logger.info(notNullStatements)\n }\n\n // @ts-expect-error drizzle-orm confusing libsql and pgsql types\n await db.execute(sql.raw(notNullStatements))\n\n // DROP TABLE\n const dropTablesStatement = sqlUpStatements.dropTable.join('\\n')\n\n if (debug) {\n payload.logger.info('DROPPING TABLES')\n payload.logger.info(dropTablesStatement)\n }\n\n // @ts-expect-error drizzle-orm confusing libsql and pgsql types\n await db.execute(sql.raw(dropTablesStatement))\n\n // DROP CONSTRAINT\n const dropConstraintsStatement = sqlUpStatements.dropConstraint.join('\\n')\n\n if (debug) {\n payload.logger.info('DROPPING CONSTRAINTS')\n payload.logger.info(dropConstraintsStatement)\n }\n\n // @ts-expect-error drizzle-orm confusing libsql and pgsql types\n await db.execute(sql.raw(dropConstraintsStatement))\n\n // DROP COLUMN\n const dropColumnsStatement = sqlUpStatements.dropColumn.join('\\n')\n\n if (debug) {\n payload.logger.info('DROPPING COLUMNS')\n payload.logger.info(dropColumnsStatement)\n }\n\n // @ts-expect-error drizzle-orm confusing libsql and pgsql types\n await db.execute(sql.raw(dropColumnsStatement))\n}\n"],"names":["sql","fs","createRequire","buildVersionCollectionFields","buildVersionGlobalFields","toSnakeCase","groupUpSQLStatements","migrateRelationships","traverseFields","require","url","migratePostgresV2toV3","debug","payload","req","adapter","db","sessions","transactionID","dir","migrationDir","generateDrizzleJson","generateMigration","drizzleJsonAfter","schema","previousSnapshot","readdirSync","filter","file","endsWith","sort","reverse","Error","drizzleJsonBefore","JSON","parse","readFileSync","generatedSQL","length","logger","info","process","exit","sqlUpStatements","addColumnsStatement","addColumn","join","execute","raw","collection","config","collections","tableName","tableNameMap","get","slug","pathsToQuery","Set","collectionSlug","columnPrefix","disableNotNull","fields","isVersions","newTableName","parentTableName","path","rootTableName","versions","versionsTableName","versionsSuffix","versionFields","versionPathsToQuery","global","globals","globalSlug","addConstraintsStatement","addConstraint","notNullStatements","notNull","dropTablesStatement","dropTable","dropConstraintsStatement","dropConstraint","dropColumnsStatement","dropColumn"],"mappings":"AAIA,SAASA,GAAG,QAAQ,cAAa;AACjC,OAAOC,QAAQ,KAAI;AACnB,SAASC,aAAa,QAAQ,SAAQ;AACtC,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAChF,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,oBAAoB,QAAQ,4BAA2B;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AAEpD,MAAMC,UAAUP,cAAc,YAAYQ,GAAG;AAQ7C;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAMC,wBAAwB,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAEC,GAAG,EAAQ;IACvE,MAAMC,UAAUF,QAAQG,EAAE;IAC1B,MAAMA,KAAKD,QAAQE,QAAQ,CAAC,MAAMH,IAAII,aAAa,CAAC,CAACF,EAAE;IACvD,MAAMG,MAAMN,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,CAACC,IAAI,CAACqC;IACtB;IAEA,gEAAgE;IAChE,MAAM7D,GAAG+B,OAAO,CAAC/C,IAAIgD,GAAG,CAAC6B;IAEzB,aAAa;IACb,MAAME,sBAAsBpC,gBAAgBqC,SAAS,CAAClC,IAAI,CAAC;IAE3D,IAAIlC,OAAO;QACTC,QAAQ0B,MAAM,CAACC,IAAI,CAAC;QACpB3B,QAAQ0B,MAAM,CAACC,IAAI,CAACuC;IACtB;IAEA,gEAAgE;IAChE,MAAM/D,GAAG+B,OAAO,CAAC/C,IAAIgD,GAAG,CAAC+B;IAEzB,kBAAkB;IAClB,MAAME,2BAA2BtC,gBAAgBuC,cAAc,CAACpC,IAAI,CAAC;IAErE,IAAIlC,OAAO;QACTC,QAAQ0B,MAAM,CAACC,IAAI,CAAC;QACpB3B,QAAQ0B,MAAM,CAACC,IAAI,CAACyC;IACtB;IAEA,gEAAgE;IAChE,MAAMjE,GAAG+B,OAAO,CAAC/C,IAAIgD,GAAG,CAACiC;IAEzB,cAAc;IACd,MAAME,uBAAuBxC,gBAAgByC,UAAU,CAACtC,IAAI,CAAC;IAE7D,IAAIlC,OAAO;QACTC,QAAQ0B,MAAM,CAACC,IAAI,CAAC;QACpB3B,QAAQ0B,MAAM,CAACC,IAAI,CAAC2C;IACtB;IAEA,gEAAgE;IAChE,MAAMnE,GAAG+B,OAAO,CAAC/C,IAAIgD,GAAG,CAACmC;AAC3B,EAAC"}
@@ -1,17 +1,18 @@
1
- import type { Field, Payload, PayloadRequestWithData } from 'payload/types';
2
- 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';
3
4
  import type { PathsToQuery } from './types.js';
4
5
  type Args = {
5
6
  adapter: PostgresAdapter;
6
7
  collectionSlug?: string;
7
- db: DrizzleTransaction;
8
+ db: TransactionPg;
8
9
  debug: boolean;
9
10
  fields: Field[];
10
11
  globalSlug?: string;
11
12
  isVersions: boolean;
12
13
  pathsToQuery: PathsToQuery;
13
14
  payload: Payload;
14
- req?: Partial<PayloadRequestWithData>;
15
+ req?: Partial<PayloadRequest>;
15
16
  tableName: string;
16
17
  };
17
18
  export declare const migrateRelationships: ({ adapter, collectionSlug, db, debug, fields, globalSlug, isVersions, pathsToQuery, payload, req, tableName, }: Args) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"migrateRelationships.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/migrateRelationships.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAI3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACzE,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,YAAY,CAAA;AAI5D,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,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAA;IACrC,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,oBAAoB,mHAY9B,IAAI,kBAkEN,CAAA"}
1
+ {"version":3,"file":"migrateRelationships.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/migrateRelationships.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,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,YAAY,CAAA;AAI5D,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,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAC7B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,oBAAoB,mHAY9B,IAAI,kBAmEN,CAAA"}
@@ -51,6 +51,7 @@ export const migrateRelationships = async ({ adapter, collectionSlug, db, debug,
51
51
  payload.logger.info('DELETING ROWS');
52
52
  payload.logger.info(deleteStatement);
53
53
  }
54
+ // @ts-expect-error drizzle-orm confusing libsql and pgsql types
54
55
  await db.execute(sql.raw(`${deleteStatement}`));
55
56
  };
56
57
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/migrateRelationships.ts"],"sourcesContent":["import type { Field, Payload, PayloadRequestWithData } from 'payload/types'\n\nimport { sql } from 'drizzle-orm'\n\nimport type { DrizzleTransaction, PostgresAdapter } from '../../types.js'\nimport type { DocsToResave, PathsToQuery } from './types.js'\n\nimport { fetchAndResave } from './fetchAndResave/index.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n db: DrizzleTransaction\n debug: boolean\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n pathsToQuery: PathsToQuery\n payload: Payload\n req?: Partial<PayloadRequestWithData>\n tableName: string\n}\n\nexport const migrateRelationships = async ({\n adapter,\n collectionSlug,\n db,\n debug,\n fields,\n globalSlug,\n isVersions,\n pathsToQuery,\n payload,\n req,\n tableName,\n}: Args) => {\n if (pathsToQuery.size === 0) return\n\n let offset = 0\n\n let paginationResult\n\n const where = Array.from(pathsToQuery).reduce((statement, path, i) => {\n return (statement += `\n\"${tableName}${adapter.relationshipsSuffix}\".\"path\" LIKE '${path}'${pathsToQuery.size !== i + 1 ? ' OR' : ''}\n`)\n }, '')\n\n while (typeof paginationResult === 'undefined' || paginationResult.rows.length > 0) {\n const paginationStatement = `SELECT DISTINCT parent_id FROM ${tableName}${adapter.relationshipsSuffix} WHERE\n ${where} ORDER BY parent_id LIMIT 500 OFFSET ${offset * 500};\n `\n\n paginationResult = await adapter.drizzle.execute(sql.raw(`${paginationStatement}`))\n\n if (paginationResult.rows.length === 0) return\n\n offset += 1\n\n const statement = `SELECT * FROM ${tableName}${adapter.relationshipsSuffix} WHERE\n (${where}) AND parent_id IN (${paginationResult.rows.map((row) => row.parent_id).join(', ')});\n`\n if (debug) {\n payload.logger.info('FINDING ROWS TO MIGRATE')\n payload.logger.info(statement)\n }\n\n const result = await adapter.drizzle.execute(sql.raw(`${statement}`))\n\n const docsToResave: DocsToResave = {}\n\n result.rows.forEach((row) => {\n const parentID = row.parent_id\n\n if (typeof parentID === 'string' || typeof parentID === 'number') {\n if (!docsToResave[parentID]) docsToResave[parentID] = []\n docsToResave[parentID].push(row)\n }\n })\n\n await fetchAndResave({\n adapter,\n collectionSlug,\n db,\n debug,\n docsToResave,\n fields,\n globalSlug,\n isVersions,\n payload,\n req: req as PayloadRequestWithData,\n tableName,\n })\n }\n\n const deleteStatement = `DELETE FROM ${tableName}${adapter.relationshipsSuffix} WHERE ${where}`\n if (debug) {\n payload.logger.info('DELETING ROWS')\n payload.logger.info(deleteStatement)\n }\n await db.execute(sql.raw(`${deleteStatement}`))\n}\n"],"names":["sql","fetchAndResave","migrateRelationships","adapter","collectionSlug","db","debug","fields","globalSlug","isVersions","pathsToQuery","payload","req","tableName","size","offset","paginationResult","where","Array","from","reduce","statement","path","i","relationshipsSuffix","rows","length","paginationStatement","drizzle","execute","raw","map","row","parent_id","join","logger","info","result","docsToResave","forEach","parentID","push","deleteStatement"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AAKjC,SAASC,cAAc,QAAQ,4BAA2B;AAgB1D,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,OAAO,EACPC,cAAc,EACdC,EAAE,EACFC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,OAAO,EACPC,GAAG,EACHC,SAAS,EACJ;IACL,IAAIH,aAAaI,IAAI,KAAK,GAAG;IAE7B,IAAIC,SAAS;IAEb,IAAIC;IAEJ,MAAMC,QAAQC,MAAMC,IAAI,CAACT,cAAcU,MAAM,CAAC,CAACC,WAAWC,MAAMC;QAC9D,OAAQF,aAAa,CAAC;CACzB,EAAER,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC,eAAe,EAAEF,KAAK,CAAC,EAAEZ,aAAaI,IAAI,KAAKS,IAAI,IAAI,QAAQ,GAAG;AAC7G,CAAC;IACC,GAAG;IAEH,MAAO,OAAOP,qBAAqB,eAAeA,iBAAiBS,IAAI,CAACC,MAAM,GAAG,EAAG;QAClF,MAAMC,sBAAsB,CAAC,+BAA+B,EAAEd,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC;IACtG,EAAEP,MAAM,qCAAqC,EAAEF,SAAS,IAAI;EAC9D,CAAC;QAECC,mBAAmB,MAAMb,QAAQyB,OAAO,CAACC,OAAO,CAAC7B,IAAI8B,GAAG,CAAC,CAAC,EAAEH,oBAAoB,CAAC;QAEjF,IAAIX,iBAAiBS,IAAI,CAACC,MAAM,KAAK,GAAG;QAExCX,UAAU;QAEV,MAAMM,YAAY,CAAC,cAAc,EAAER,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC;KAC1E,EAAEP,MAAM,oBAAoB,EAAED,iBAAiBS,IAAI,CAACM,GAAG,CAAC,CAACC,MAAQA,IAAIC,SAAS,EAAEC,IAAI,CAAC,MAAM;AAChG,CAAC;QACG,IAAI5B,OAAO;YACTK,QAAQwB,MAAM,CAACC,IAAI,CAAC;YACpBzB,QAAQwB,MAAM,CAACC,IAAI,CAACf;QACtB;QAEA,MAAMgB,SAAS,MAAMlC,QAAQyB,OAAO,CAACC,OAAO,CAAC7B,IAAI8B,GAAG,CAAC,CAAC,EAAET,UAAU,CAAC;QAEnE,MAAMiB,eAA6B,CAAC;QAEpCD,OAAOZ,IAAI,CAACc,OAAO,CAAC,CAACP;YACnB,MAAMQ,WAAWR,IAAIC,SAAS;YAE9B,IAAI,OAAOO,aAAa,YAAY,OAAOA,aAAa,UAAU;gBAChE,IAAI,CAACF,YAAY,CAACE,SAAS,EAAEF,YAAY,CAACE,SAAS,GAAG,EAAE;gBACxDF,YAAY,CAACE,SAAS,CAACC,IAAI,CAACT;YAC9B;QACF;QAEA,MAAM/B,eAAe;YACnBE;YACAC;YACAC;YACAC;YACAgC;YACA/B;YACAC;YACAC;YACAE;YACAC,KAAKA;YACLC;QACF;IACF;IAEA,MAAM6B,kBAAkB,CAAC,YAAY,EAAE7B,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC,OAAO,EAAEP,MAAM,CAAC;IAC/F,IAAIX,OAAO;QACTK,QAAQwB,MAAM,CAACC,IAAI,CAAC;QACpBzB,QAAQwB,MAAM,CAACC,IAAI,CAACM;IACtB;IACA,MAAMrC,GAAGwB,OAAO,CAAC7B,IAAI8B,GAAG,CAAC,CAAC,EAAEY,gBAAgB,CAAC;AAC/C,EAAC"}
1
+ {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/migrateRelationships.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\nimport type { Field, Payload, PayloadRequest } from 'payload'\n\nimport { sql } from 'drizzle-orm'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { DocsToResave, PathsToQuery } from './types.js'\n\nimport { fetchAndResave } from './fetchAndResave/index.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n db: TransactionPg\n debug: boolean\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n pathsToQuery: PathsToQuery\n payload: Payload\n req?: Partial<PayloadRequest>\n tableName: string\n}\n\nexport const migrateRelationships = async ({\n adapter,\n collectionSlug,\n db,\n debug,\n fields,\n globalSlug,\n isVersions,\n pathsToQuery,\n payload,\n req,\n tableName,\n}: Args) => {\n if (pathsToQuery.size === 0) return\n\n let offset = 0\n\n let paginationResult\n\n const where = Array.from(pathsToQuery).reduce((statement, path, i) => {\n return (statement += `\n\"${tableName}${adapter.relationshipsSuffix}\".\"path\" LIKE '${path}'${pathsToQuery.size !== i + 1 ? ' OR' : ''}\n`)\n }, '')\n\n while (typeof paginationResult === 'undefined' || paginationResult.rows.length > 0) {\n const paginationStatement = `SELECT DISTINCT parent_id FROM ${tableName}${adapter.relationshipsSuffix} WHERE\n ${where} ORDER BY parent_id LIMIT 500 OFFSET ${offset * 500};\n `\n\n paginationResult = await adapter.drizzle.execute(sql.raw(`${paginationStatement}`))\n\n if (paginationResult.rows.length === 0) return\n\n offset += 1\n\n const statement = `SELECT * FROM ${tableName}${adapter.relationshipsSuffix} WHERE\n (${where}) AND parent_id IN (${paginationResult.rows.map((row) => row.parent_id).join(', ')});\n`\n if (debug) {\n payload.logger.info('FINDING ROWS TO MIGRATE')\n payload.logger.info(statement)\n }\n\n const result = await adapter.drizzle.execute(sql.raw(`${statement}`))\n\n const docsToResave: DocsToResave = {}\n\n result.rows.forEach((row) => {\n const parentID = row.parent_id\n\n if (typeof parentID === 'string' || typeof parentID === 'number') {\n if (!docsToResave[parentID]) docsToResave[parentID] = []\n docsToResave[parentID].push(row)\n }\n })\n\n await fetchAndResave({\n adapter,\n collectionSlug,\n db,\n debug,\n docsToResave,\n fields,\n globalSlug,\n isVersions,\n payload,\n req: req as unknown as PayloadRequest,\n tableName,\n })\n }\n\n const deleteStatement = `DELETE FROM ${tableName}${adapter.relationshipsSuffix} WHERE ${where}`\n if (debug) {\n payload.logger.info('DELETING ROWS')\n payload.logger.info(deleteStatement)\n }\n // @ts-expect-error drizzle-orm confusing libsql and pgsql types\n await db.execute(sql.raw(`${deleteStatement}`))\n}\n"],"names":["sql","fetchAndResave","migrateRelationships","adapter","collectionSlug","db","debug","fields","globalSlug","isVersions","pathsToQuery","payload","req","tableName","size","offset","paginationResult","where","Array","from","reduce","statement","path","i","relationshipsSuffix","rows","length","paginationStatement","drizzle","execute","raw","map","row","parent_id","join","logger","info","result","docsToResave","forEach","parentID","push","deleteStatement"],"mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AAKjC,SAASC,cAAc,QAAQ,4BAA2B;AAgB1D,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,OAAO,EACPC,cAAc,EACdC,EAAE,EACFC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,OAAO,EACPC,GAAG,EACHC,SAAS,EACJ;IACL,IAAIH,aAAaI,IAAI,KAAK,GAAG;IAE7B,IAAIC,SAAS;IAEb,IAAIC;IAEJ,MAAMC,QAAQC,MAAMC,IAAI,CAACT,cAAcU,MAAM,CAAC,CAACC,WAAWC,MAAMC;QAC9D,OAAQF,aAAa,CAAC;CACzB,EAAER,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC,eAAe,EAAEF,KAAK,CAAC,EAAEZ,aAAaI,IAAI,KAAKS,IAAI,IAAI,QAAQ,GAAG;AAC7G,CAAC;IACC,GAAG;IAEH,MAAO,OAAOP,qBAAqB,eAAeA,iBAAiBS,IAAI,CAACC,MAAM,GAAG,EAAG;QAClF,MAAMC,sBAAsB,CAAC,+BAA+B,EAAEd,UAAU,EAAEV,QAAQqB,mBAAmB,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AQwB,MAAM,CAACC,IAAI,CAACM;IACtB;IACA,gEAAgE;IAChE,MAAMrC,GAAGwB,OAAO,CAAC7B,IAAI8B,GAAG,CAAC,CAAC,EAAEY,gBAAgB,CAAC;AAC/C,EAAC"}
@@ -1,12 +1,12 @@
1
- import type { Payload } from 'payload';
2
- import { type Field } from 'payload/types';
3
- import type { DrizzleTransaction, PostgresAdapter } from '../../types.js';
1
+ import type { TransactionPg } from '@payloadcms/drizzle/types';
2
+ import type { Field, Payload } from 'payload';
3
+ import type { PostgresAdapter } from '../../types.js';
4
4
  import type { PathsToQuery } from './types.js';
5
5
  type Args = {
6
6
  adapter: PostgresAdapter;
7
7
  collectionSlug?: string;
8
8
  columnPrefix: string;
9
- db: DrizzleTransaction;
9
+ db: TransactionPg;
10
10
  disableNotNull: boolean;
11
11
  fields: Field[];
12
12
  globalSlug?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,eAAe,CAAA;AAGtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,EAAE,EAAE,kBAAkB,CAAA;IACtB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,SAAU,IAAI,SA0FxC,CAAA"}
1
+ {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAK7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,EAAE,EAAE,aAAa,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,SAAU,IAAI,SA0FxC,CAAA"}
@@ -1,4 +1,4 @@
1
- import { tabHasName } from 'payload/types';
1
+ import { tabHasName } from 'payload/shared';
2
2
  import toSnakeCase from 'to-snake-case';
3
3
  export const traverseFields = (args)=>{
4
4
  args.fields.forEach((field)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/traverseFields.ts"],"sourcesContent":["import type { Payload } from 'payload'\n\nimport { type Field, tabHasName } from 'payload/types'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleTransaction, PostgresAdapter } from '../../types.js'\nimport type { PathsToQuery } from './types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n columnPrefix: string\n db: DrizzleTransaction\n disableNotNull: boolean\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n newTableName: string\n parentTableName: string\n path: string\n pathsToQuery: PathsToQuery\n payload: Payload\n rootTableName: string\n}\n\nexport const traverseFields = (args: Args) => {\n args.fields.forEach((field) => {\n switch (field.type) {\n case 'group': {\n let newTableName = `${args.newTableName}_${toSnakeCase(field.name)}`\n\n if (field.localized && args.payload.config.localization) {\n newTableName += args.adapter.localesSuffix\n }\n\n return traverseFields({\n ...args,\n columnPrefix: `${args.columnPrefix}${toSnakeCase(field.name)}_`,\n fields: field.fields,\n newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}`,\n })\n }\n\n case 'row':\n case 'collapsible': {\n return traverseFields({\n ...args,\n fields: field.fields,\n })\n }\n\n case 'array': {\n const newTableName = args.adapter.tableNameMap.get(\n `${args.newTableName}_${toSnakeCase(field.name)}`,\n )\n\n return traverseFields({\n ...args,\n columnPrefix: '',\n fields: field.fields,\n newTableName,\n parentTableName: newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}.%`,\n })\n }\n\n case 'blocks': {\n return field.blocks.forEach((block) => {\n const newTableName = args.adapter.tableNameMap.get(\n `${args.rootTableName}_blocks_${toSnakeCase(block.slug)}`,\n )\n\n traverseFields({\n ...args,\n columnPrefix: '',\n fields: block.fields,\n newTableName,\n parentTableName: newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}.%`,\n })\n })\n }\n\n case 'tabs': {\n return field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n args.columnPrefix = `${args.columnPrefix}_${toSnakeCase(tab.name)}_`\n args.path = `${args.path ? `${args.path}.` : ''}${tab.name}`\n args.newTableName = `${args.newTableName}_${toSnakeCase(tab.name)}`\n\n if (tab.localized && args.payload.config.localization) {\n args.newTableName += args.adapter.localesSuffix\n }\n }\n\n traverseFields({\n ...args,\n fields: tab.fields,\n })\n })\n }\n\n case 'relationship':\n case 'upload': {\n if (typeof field.relationTo === 'string') {\n if (field.type === 'upload' || !field.hasMany) {\n args.pathsToQuery.add(`${args.path ? `${args.path}.` : ''}${field.name}`)\n }\n }\n\n return null\n }\n }\n })\n}\n"],"names":["tabHasName","toSnakeCase","traverseFields","args","fields","forEach","field","type","newTableName","name","localized","payload","config","localization","adapter","localesSuffix","columnPrefix","path","tableNameMap","get","parentTableName","blocks","block","rootTableName","slug","tabs","tab","relationTo","hasMany","pathsToQuery","add"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAAqBA,UAAU,QAAQ,gBAAe;AACtD,OAAOC,iBAAiB,gBAAe;AAsBvC,OAAO,MAAMC,iBAAiB,CAACC;IAC7BA,KAAKC,MAAM,CAACC,OAAO,CAAC,CAACC;QACnB,OAAQA,MAAMC,IAAI;YAChB,KAAK;gBAAS;oBACZ,IAAIC,eAAe,CAAC,EAAEL,KAAKK,YAAY,CAAC,CAAC,EAAEP,YAAYK,MAAMG,IAAI,EAAE,CAAC;oBAEpE,IAAIH,MAAMI,SAAS,IAAIP,KAAKQ,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;wBACvDL,gBAAgBL,KAAKW,OAAO,CAACC,aAAa;oBAC5C;oBAEA,OAAOb,eAAe;wBACpB,GAAGC,IAAI;wBACPa,cAAc,CAAC,EAAEb,KAAKa,YAAY,CAAC,EAAEf,YAAYK,MAAMG,IAAI,EAAE,CAAC,CAAC;wBAC/DL,QAAQE,MAAMF,MAAM;wBACpBI;wBACAS,MAAM,CAAC,EAAEd,KAAK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,IAAI1B,WAAW0B,MAAM;4BACnBvB,KAAKa,YAAY,GAAG,CAAC,EAAEb,KAAKa,YAAY,CAAC,CAAC,EAAEf,YAAYyB,IAAIjB,IAAI,EAAE,CAAC,CAAC;4BACpEN,KAAKc,IAAI,GAAG,CAAC,EAAEd,KAAKc,IAAI,GAAG,CAAC,EAAEd,KAAKc,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,EAAES,IAAIjB,IAAI,CAAC,CAAC;4BAC5DN,KAAKK,YAAY,GAAG,CAAC,EAAEL,KAAKK,YAAY,CAAC,CAAC,EAAEP,YAAYyB,IAAIjB,IAAI,EAAE,CAAC;4BAEnE,IAAIiB,IAAIhB,SAAS,IAAIP,KAAKQ,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;gCACrDV,KAAKK,YAAY,IAAIL,KAAKW,OAAO,CAACC,aAAa;4BACjD;wBACF;wBAEAb,eAAe;4BACb,GAAGC,IAAI;4BACPC,QAAQsB,IAAItB,MAAM;wBACpB;oBACF;gBACF;YAEA,KAAK;YACL,KAAK;gBAAU;oBACb,IAAI,OAAOE,MAAMqB,UAAU,KAAK,UAAU;wBACxC,IAAIrB,MAAMC,IAAI,KAAK,YAAY,CAACD,MAAMsB,OAAO,EAAE;4BAC7CzB,KAAK0B,YAAY,CAACC,GAAG,CAAC,CAAC,EAAE3B,KAAKc,IAAI,GAAG,CAAC,EAAEd,KAAKc,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,EAAEX,MAAMG,IAAI,CAAC,CAAC;wBAC1E;oBACF;oBAEA,OAAO;gBACT;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/traverseFields.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\nimport type { Field, Payload } from 'payload'\n\nimport { tabHasName } from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { PathsToQuery } from './types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n columnPrefix: string\n db: TransactionPg\n disableNotNull: boolean\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n newTableName: string\n parentTableName: string\n path: string\n pathsToQuery: PathsToQuery\n payload: Payload\n rootTableName: string\n}\n\nexport const traverseFields = (args: Args) => {\n args.fields.forEach((field) => {\n switch (field.type) {\n case 'group': {\n let newTableName = `${args.newTableName}_${toSnakeCase(field.name)}`\n\n if (field.localized && args.payload.config.localization) {\n newTableName += args.adapter.localesSuffix\n }\n\n return traverseFields({\n ...args,\n columnPrefix: `${args.columnPrefix}${toSnakeCase(field.name)}_`,\n fields: field.fields,\n newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}`,\n })\n }\n\n case 'row':\n case 'collapsible': {\n return traverseFields({\n ...args,\n fields: field.fields,\n })\n }\n\n case 'array': {\n const newTableName = args.adapter.tableNameMap.get(\n `${args.newTableName}_${toSnakeCase(field.name)}`,\n )\n\n return traverseFields({\n ...args,\n columnPrefix: '',\n fields: field.fields,\n newTableName,\n parentTableName: newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}.%`,\n })\n }\n\n case 'blocks': {\n return field.blocks.forEach((block) => {\n const newTableName = args.adapter.tableNameMap.get(\n `${args.rootTableName}_blocks_${toSnakeCase(block.slug)}`,\n )\n\n traverseFields({\n ...args,\n columnPrefix: '',\n fields: block.fields,\n newTableName,\n parentTableName: newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}.%`,\n })\n })\n }\n\n case 'tabs': {\n return field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n args.columnPrefix = `${args.columnPrefix}_${toSnakeCase(tab.name)}_`\n args.path = `${args.path ? `${args.path}.` : ''}${tab.name}`\n args.newTableName = `${args.newTableName}_${toSnakeCase(tab.name)}`\n\n if (tab.localized && args.payload.config.localization) {\n args.newTableName += args.adapter.localesSuffix\n }\n }\n\n traverseFields({\n ...args,\n fields: tab.fields,\n })\n })\n }\n\n case 'relationship':\n case 'upload': {\n if (typeof field.relationTo === 'string') {\n if (field.type === 'upload' || !field.hasMany) {\n args.pathsToQuery.add(`${args.path ? `${args.path}.` : ''}${field.name}`)\n }\n }\n\n return null\n }\n }\n })\n}\n"],"names":["tabHasName","toSnakeCase","traverseFields","args","fields","forEach","field","type","newTableName","name","localized","payload","config","localization","adapter","localesSuffix","columnPrefix","path","tableNameMap","get","parentTableName","blocks","block","rootTableName","slug","tabs","tab","relationTo","hasMany","pathsToQuery","add"],"mappings":"AAGA,SAASA,UAAU,QAAQ,iBAAgB;AAC3C,OAAOC,iBAAiB,gBAAe;AAsBvC,OAAO,MAAMC,iBAAiB,CAACC;IAC7BA,KAAKC,MAAM,CAACC,OAAO,CAAC,CAACC;QACnB,OAAQA,MAAMC,IAAI;YAChB,KAAK;gBAAS;oBACZ,IAAIC,eAAe,CAAC,EAAEL,KAAKK,YAAY,CAAC,CAAC,EAAEP,YAAYK,MAAMG,IAAI,EAAE,CAAC;oBAEpE,IAAIH,MAAMI,SAAS,IAAIP,KAAKQ,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;wBACvDL,gBAAgBL,KAAKW,OAAO,CAACC,aAAa;oBAC5C;oBAEA,OAAOb,eAAe;wBACpB,GAAGC,IAAI;wBACPa,cAAc,CAAC,EAAEb,KAAKa,YAAY,CAAC,EAAEf,YAAYK,MAAMG,IAAI,EAAE,CAAC,CAAC;wBAC/DL,QAAQE,MAAMF,MAAM;wBACpBI;wBACAS,MAAM,CAAC,EAAEd,KAAKc,IAAI,GAAG,CAAC,EAAEd,KAAKc,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,EAAEX,MAAMG,IAAI,CAAC,CAAC;oBAC1D;gBACF;YAEA,KAAK;YACL,KAAK;gBAAe;oBAClB,OAAOP,eAAe;wBACpB,GAAGC,IAAI;wBACPC,QAAQE,MAAMF,MAAM;oBACtB;gBACF;YAEA,KAAK;gBAAS;oBACZ,MAAMI,eAAeL,KAAKW,OAAO,CAACI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4BAC5DN,KAAKK,YAAY,GAAG,CAAC,EAAEL,KAAKK,YAAY,CAAC,CAAC,EAAEP,YAAYyB,IAAIjB,IAAI,EAAE,CAAC;4BAEnE,IAAIiB,IAAIhB,SAAS,IAAIP,KAAKQ,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;gCACrDV,KAAKK,YAAY,IAAIL,KAAKW,OAAO,CAACC,aAAa;4BACjD;wBACF;wBAEAb,eAAe;4BACb,GAAGC,IAAI;4BACPC,QAAQsB,IAAItB,MAAM;wBACpB;oBACF;gBACF;YAEA,KAAK;YACL,KAAK;gBAAU;oBACb,IAAI,OAAOE,MAAMqB,UAAU,KAAK,UAAU;wBACxC,IAAIrB,MAAMC,IAAI,KAAK,YAAY,CAACD,MAAMsB,OAAO,EAAE;4BAC7CzB,KAAK0B,YAAY,CAACC,GAAG,CAAC,CAAC,EAAE3B,KAAKc,IAAI,GAAG,CAAC,EAAEd,KAAKc,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,EAAEX,MAAMG,IAAI,CAAC,CAAC;wBAC1E;oBACF;oBAEA,OAAO;gBACT;QACF;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/types.ts"],"sourcesContent":["/**\n * Set of all paths which should be moved\n * This will be built up into one WHERE query\n */\nexport type PathsToQuery = Set<string>\n\nexport type DocsToResave = {\n [id: number | string]: Record<string, unknown>[]\n}\n"],"names":[],"rangeMappings":";;;","mappings":"AAAA;;;CAGC,GAGD,WAEC"}
1
+ {"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/types.ts"],"sourcesContent":["/**\n * Set of all paths which should be moved\n * This will be built up into one WHERE query\n */\nexport type PathsToQuery = Set<string>\n\nexport type DocsToResave = {\n [id: number | string]: Record<string, unknown>[]\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAGD,WAEC"}
@@ -0,0 +1,3 @@
1
+ import type { RequireDrizzleKit } from '@payloadcms/drizzle/types';
2
+ export declare const requireDrizzleKit: RequireDrizzleKit;
3
+ //# sourceMappingURL=requireDrizzleKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireDrizzleKit.d.ts","sourceRoot":"","sources":["../src/requireDrizzleKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAIlE,eAAO,MAAM,iBAAiB,EAAE,iBAAwD,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'module';
2
+ const require = createRequire(import.meta.url);
3
+ export const requireDrizzleKit = ()=>require('drizzle-kit/payload');
4
+
5
+ //# sourceMappingURL=requireDrizzleKit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/requireDrizzleKit.ts"],"sourcesContent":["import type { RequireDrizzleKit } from '@payloadcms/drizzle/types'\n\nimport { createRequire } from 'module'\nconst require = createRequire(import.meta.url)\nexport const requireDrizzleKit: RequireDrizzleKit = () => require('drizzle-kit/payload')\n"],"names":["createRequire","require","url","requireDrizzleKit"],"mappings":"AAEA,SAASA,aAAa,QAAQ,SAAQ;AACtC,MAAMC,UAAUD,cAAc,YAAYE,GAAG;AAC7C,OAAO,MAAMC,oBAAuC,IAAMF,QAAQ,uBAAsB"}
@@ -1,5 +1,5 @@
1
1
  import type { ForeignKeyBuilder, IndexBuilder, PgColumnBuilder, UniqueConstraintBuilder } from 'drizzle-orm/pg-core';
2
- import type { Field } from 'payload/types';
2
+ import type { Field } from 'payload';
3
3
  import type { GenericColumns, PostgresAdapter } from '../types.js';
4
4
  export type BaseExtraConfig = Record<string, (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder>;
5
5
  export type RelationMap = Map<string, {
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/schema/build.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAEf,uBAAuB,EACx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,CAAA;CAClB,CAAA;AAED,KAAK,MAAM,GAAG;IACZ,kBAAkB,EAAE,OAAO,GAAG,OAAO,CAAA;IACrC,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAA;IACnC,gBAAgB,EAAE,WAAW,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,UAAU,0NAcpB,IAAI,KAAG,MAqYT,CAAA"}
@@ -1,7 +1,7 @@
1
- /* eslint-disable no-param-reassign */ import { relations } from 'drizzle-orm';
1
+ /* eslint-disable no-param-reassign */ import { createTableName } from '@payloadcms/drizzle';
2
+ import { relations } from 'drizzle-orm';
2
3
  import { foreignKey, index, integer, numeric, serial, timestamp, unique, varchar } from 'drizzle-orm/pg-core';
3
4
  import toSnakeCase from 'to-snake-case';
4
- import { createTableName } from './createTableName.js';
5
5
  import { parentIDColumnMap } from './parentIDColumnMap.js';
6
6
  import { setColumnID } from './setColumnID.js';
7
7
  import { traverseFields } from './traverseFields.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/build.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Relation } from 'drizzle-orm'\nimport type {\n ForeignKeyBuilder,\n IndexBuilder,\n PgColumnBuilder,\n PgTableWithColumns,\n UniqueConstraintBuilder,\n} from 'drizzle-orm/pg-core'\nimport type { Field } from 'payload/types'\n\nimport { relations } from 'drizzle-orm'\nimport {\n foreignKey,\n index,\n integer,\n numeric,\n serial,\n timestamp,\n unique,\n varchar,\n} from 'drizzle-orm/pg-core'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { GenericColumns, GenericTable, IDType, PostgresAdapter } from '../types.js'\n\nimport { createTableName } from './createTableName.js'\nimport { parentIDColumnMap } from './parentIDColumnMap.js'\nimport { setColumnID } from './setColumnID.js'\nimport { traverseFields } from './traverseFields.js'\n\nexport type BaseExtraConfig = Record<\n string,\n (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder\n>\n\nexport type RelationMap = Map<string, { localized: boolean; target: string; type: 'many' | 'one' }>\n\ntype Args = {\n adapter: PostgresAdapter\n baseColumns?: Record<string, PgColumnBuilder>\n baseExtraConfig?: BaseExtraConfig\n buildNumbers?: boolean\n buildRelationships?: boolean\n disableNotNull: boolean\n disableUnique: boolean\n fields: Field[]\n rootRelationsToBuild?: RelationMap\n rootRelationships?: Set<string>\n rootTableIDColType?: string\n rootTableName?: string\n tableName: string\n timestamps?: boolean\n versions: boolean\n}\n\ntype Result = {\n hasManyNumberField: 'index' | boolean\n hasManyTextField: 'index' | boolean\n relationsToBuild: RelationMap\n}\n\nexport const buildTable = ({\n adapter,\n baseColumns = {},\n baseExtraConfig = {},\n disableNotNull,\n disableUnique = false,\n fields,\n rootRelationsToBuild,\n rootRelationships,\n rootTableIDColType,\n rootTableName: incomingRootTableName,\n tableName,\n timestamps,\n versions,\n}: Args): Result => {\n const isRoot = !incomingRootTableName\n const rootTableName = incomingRootTableName || tableName\n const columns: Record<string, PgColumnBuilder> = baseColumns\n const indexes: Record<string, (cols: GenericColumns) => IndexBuilder> = {}\n\n const localesColumns: Record<string, PgColumnBuilder> = {}\n const localesIndexes: Record<string, (cols: GenericColumns) => IndexBuilder> = {}\n let localesTable: GenericTable | PgTableWithColumns<any>\n let textsTable: GenericTable | PgTableWithColumns<any>\n let numbersTable: GenericTable | PgTableWithColumns<any>\n\n // Relationships to the base collection\n const relationships: Set<string> = rootRelationships || new Set()\n\n let relationshipsTable: GenericTable | PgTableWithColumns<any>\n\n // Drizzle relations\n const relationsToBuild: RelationMap = new Map()\n\n const idColType: IDType = setColumnID({ adapter, columns, fields })\n\n const {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n } = traverseFields({\n adapter,\n columns,\n disableNotNull,\n disableUnique,\n fields,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: tableName,\n parentTableName: tableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild: rootRelationsToBuild || relationsToBuild,\n rootTableIDColType: rootTableIDColType || idColType,\n rootTableName,\n versions,\n })\n\n // split the relationsToBuild by localized and non-localized\n const localizedRelations = new Map()\n const nonLocalizedRelations = new Map()\n\n relationsToBuild.forEach(({ type, localized, target }, key) => {\n const map = localized ? localizedRelations : nonLocalizedRelations\n map.set(key, { type, target })\n })\n\n if (timestamps) {\n columns.createdAt = timestamp('created_at', {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n .defaultNow()\n .notNull()\n columns.updatedAt = timestamp('updated_at', {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n .defaultNow()\n .notNull()\n }\n\n const table = adapter.pgSchema.table(tableName, columns, (cols) => {\n const extraConfig = Object.entries(baseExtraConfig).reduce((config, [key, func]) => {\n config[key] = func(cols)\n return config\n }, {})\n\n const result = Object.entries(indexes).reduce((acc, [colName, func]) => {\n acc[colName] = func(cols)\n return acc\n }, extraConfig)\n\n return result\n })\n\n adapter.tables[tableName] = table\n\n if (hasLocalizedField || localizedRelations.size) {\n const localeTableName = `${tableName}${adapter.localesSuffix}`\n localesColumns.id = serial('id').primaryKey()\n localesColumns._locale = adapter.enums.enum__locales('_locale').notNull()\n localesColumns._parentID = parentIDColumnMap[idColType]('_parent_id').notNull()\n\n localesTable = adapter.pgSchema.table(localeTableName, localesColumns, (cols) => {\n return Object.entries(localesIndexes).reduce(\n (acc, [colName, func]) => {\n acc[colName] = func(cols)\n return acc\n },\n {\n _localeParent: unique(`${localeTableName}_locale_parent_id_unique`).on(\n cols._locale,\n cols._parentID,\n ),\n _parentIdFk: foreignKey({\n name: `${localeTableName}_parent_id_fk`,\n columns: [cols._parentID],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n },\n )\n })\n\n adapter.tables[localeTableName] = localesTable\n\n adapter.relations[`relations_${localeTableName}`] = relations(localesTable, ({ many, one }) => {\n const result: Record<string, Relation<string>> = {}\n\n result._parentID = one(table, {\n fields: [localesTable._parentID],\n references: [table.id],\n // name the relationship by what the many() relationName is\n relationName: '_locales',\n })\n\n localizedRelations.forEach(({ type, target }, key) => {\n if (type === 'one') {\n result[key] = one(adapter.tables[target], {\n fields: [localesTable[key]],\n references: [adapter.tables[target].id],\n relationName: key,\n })\n }\n if (type === 'many') {\n result[key] = many(adapter.tables[target], {\n relationName: key,\n })\n }\n })\n\n return result\n })\n }\n\n if (isRoot) {\n if (hasManyTextField) {\n const textsTableName = `${rootTableName}_texts`\n const columns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n order: integer('order').notNull(),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n text: varchar('text'),\n }\n\n if (hasLocalizedManyTextField) {\n columns.locale = adapter.enums.enum__locales('locale')\n }\n\n textsTable = adapter.pgSchema.table(textsTableName, columns, (cols) => {\n const config: Record<string, ForeignKeyBuilder | IndexBuilder> = {\n orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent),\n parentFk: foreignKey({\n name: `${textsTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n }\n\n if (hasManyTextField === 'index') {\n config.text_idx = index(`${textsTableName}_text_idx`).on(cols.text)\n }\n\n if (hasLocalizedManyTextField) {\n config.localeParent = index(`${textsTableName}_locale_parent`).on(\n cols.locale,\n cols.parent,\n )\n }\n\n return config\n })\n\n adapter.tables[textsTableName] = textsTable\n\n adapter.relations[`relations_${textsTableName}`] = relations(textsTable, ({ one }) => ({\n parent: one(table, {\n fields: [textsTable.parent],\n references: [table.id],\n relationName: '_texts',\n }),\n }))\n }\n\n if (hasManyNumberField) {\n const numbersTableName = `${rootTableName}_numbers`\n const columns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n number: numeric('number'),\n order: integer('order').notNull(),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n }\n\n if (hasLocalizedManyNumberField) {\n columns.locale = adapter.enums.enum__locales('locale')\n }\n\n numbersTable = adapter.pgSchema.table(numbersTableName, columns, (cols) => {\n const config: Record<string, ForeignKeyBuilder | IndexBuilder> = {\n orderParentIdx: index(`${numbersTableName}_order_parent_idx`).on(cols.order, cols.parent),\n parentFk: foreignKey({\n name: `${numbersTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n }\n\n if (hasManyNumberField === 'index') {\n config.numberIdx = index(`${numbersTableName}_number_idx`).on(cols.number)\n }\n\n if (hasLocalizedManyNumberField) {\n config.localeParent = index(`${numbersTableName}_locale_parent`).on(\n cols.locale,\n cols.parent,\n )\n }\n\n return config\n })\n\n adapter.tables[numbersTableName] = numbersTable\n\n adapter.relations[`relations_${numbersTableName}`] = relations(numbersTable, ({ one }) => ({\n parent: one(table, {\n fields: [numbersTable.parent],\n references: [table.id],\n relationName: '_numbers',\n }),\n }))\n }\n\n if (relationships.size) {\n const relationshipColumns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n order: integer('order'),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n }\n\n if (hasLocalizedRelationshipField) {\n relationshipColumns.locale = adapter.enums.enum__locales('locale')\n }\n\n const relationExtraConfig: BaseExtraConfig = {}\n const relationshipsTableName = `${tableName}${adapter.relationshipsSuffix}`\n\n relationships.forEach((relationTo) => {\n const relationshipConfig = adapter.payload.collections[relationTo].config\n const formattedRelationTo = createTableName({\n adapter,\n config: relationshipConfig,\n throwValidationError: true,\n })\n let colType = adapter.idType === 'uuid' ? 'uuid' : 'integer'\n const relatedCollectionCustomIDType =\n adapter.payload.collections[relationshipConfig.slug]?.customIDType\n\n if (relatedCollectionCustomIDType === 'number') colType = 'numeric'\n if (relatedCollectionCustomIDType === 'text') colType = 'varchar'\n\n relationshipColumns[`${relationTo}ID`] = parentIDColumnMap[colType](\n `${formattedRelationTo}_id`,\n )\n\n relationExtraConfig[`${relationTo}IdFk`] = (cols) =>\n foreignKey({\n name: `${relationshipsTableName}_${toSnakeCase(relationTo)}_fk`,\n columns: [cols[`${relationTo}ID`]],\n foreignColumns: [adapter.tables[formattedRelationTo].id],\n }).onDelete('cascade')\n })\n\n relationshipsTable = adapter.pgSchema.table(\n relationshipsTableName,\n relationshipColumns,\n (cols) => {\n const result: Record<string, ForeignKeyBuilder | IndexBuilder> = Object.entries(\n relationExtraConfig,\n ).reduce(\n (config, [key, func]) => {\n config[key] = func(cols)\n return config\n },\n {\n order: index(`${relationshipsTableName}_order_idx`).on(cols.order),\n parentFk: foreignKey({\n name: `${relationshipsTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n parentIdx: index(`${relationshipsTableName}_parent_idx`).on(cols.parent),\n pathIdx: index(`${relationshipsTableName}_path_idx`).on(cols.path),\n },\n )\n\n if (hasLocalizedRelationshipField) {\n result.localeIdx = index(`${relationshipsTableName}_locale_idx`).on(cols.locale)\n }\n\n return result\n },\n )\n\n adapter.tables[relationshipsTableName] = relationshipsTable\n\n adapter.relations[`relations_${relationshipsTableName}`] = relations(\n relationshipsTable,\n ({ one }) => {\n const result: Record<string, Relation<string>> = {\n parent: one(table, {\n fields: [relationshipsTable.parent],\n references: [table.id],\n relationName: '_rels',\n }),\n }\n\n relationships.forEach((relationTo) => {\n const relatedTableName = createTableName({\n adapter,\n config: adapter.payload.collections[relationTo].config,\n throwValidationError: true,\n })\n const idColumnName = `${relationTo}ID`\n result[idColumnName] = one(adapter.tables[relatedTableName], {\n fields: [relationshipsTable[idColumnName]],\n references: [adapter.tables[relatedTableName].id],\n relationName: relationTo,\n })\n })\n\n return result\n },\n )\n }\n }\n\n adapter.relations[`relations_${tableName}`] = relations(table, ({ many, one }) => {\n const result: Record<string, Relation<string>> = {}\n\n nonLocalizedRelations.forEach(({ type, target }, key) => {\n if (type === 'one') {\n result[key] = one(adapter.tables[target], {\n fields: [table[key]],\n references: [adapter.tables[target].id],\n relationName: key,\n })\n }\n if (type === 'many') {\n result[key] = many(adapter.tables[target], { relationName: key })\n }\n })\n\n if (hasLocalizedField) {\n result._locales = many(localesTable, { relationName: '_locales' })\n }\n\n if (hasManyTextField) {\n result._texts = many(textsTable, { relationName: '_texts' })\n }\n\n if (hasManyNumberField) {\n result._numbers = many(numbersTable, { relationName: '_numbers' })\n }\n\n if (relationships.size && relationshipsTable) {\n result._rels = many(relationshipsTable, {\n relationName: '_rels',\n })\n }\n\n return result\n })\n\n return { hasManyNumberField, hasManyTextField, relationsToBuild }\n}\n"],"names":["relations","foreignKey","index","integer","numeric","serial","timestamp","unique","varchar","toSnakeCase","createTableName","parentIDColumnMap","setColumnID","traverseFields","buildTable","adapter","baseColumns","baseExtraConfig","disableNotNull","disableUnique","fields","rootRelationsToBuild","rootRelationships","rootTableIDColType","rootTableName","incomingRootTableName","tableName","timestamps","versions","isRoot","columns","indexes","localesColumns","localesIndexes","localesTable","textsTable","numbersTable","relationships","Set","relationshipsTable","relationsToBuild","Map","idColType","hasLocalizedField","hasLocalizedManyNumberField","hasLocalizedManyTextField","hasLocalizedRelationshipField","hasManyNumberField","hasManyTextField","newTableName","parentTableName","localizedRelations","nonLocalizedRelations","forEach","type","localized","target","key","map","set","createdAt","mode","precision","withTimezone","defaultNow","notNull","updatedAt","table","pgSchema","cols","extraConfig","Object","entries","reduce","config","func","result","acc","colName","tables","size","localeTableName","localesSuffix","id","primaryKey","_locale","enums","enum__locales","_parentID","_localeParent","on","_parentIdFk","name","foreignColumns","onDelete","many","one","references","relationName","textsTableName","order","parent","path","text","locale","orderParentIdx","parentFk","text_idx","localeParent","numbersTableName","number","numberIdx","relationshipColumns","relationExtraConfig","relationshipsTableName","relationshipsSuffix","relationTo","relationshipConfig","payload","collections","formattedRelationTo","throwValidationError","colType","idType","relatedCollectionCustomIDType","slug","customIDType","parentIdx","pathIdx","localeIdx","relatedTableName","idColumnName","_locales","_texts","_numbers","_rels"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAQgE,MAAM,CAACvB,OAAO,EAAE;oBAAE0C,cAAczC;gBAAI;YACjE;QACF;QAEA,IAAId,mBAAmB;YACrBiC,OAAOwD,QAAQ,GAAGrC,KAAK7D,cAAc;gBAAEgE,cAAc;YAAW;QAClE;QAEA,IAAIlD,kBAAkB;YACpB4B,OAAOyD,MAAM,GAAGtC,KAAK5D,YAAY;gBAAE+D,cAAc;YAAS;QAC5D;QAEA,IAAInD,oBAAoB;YACtB6B,OAAO0D,QAAQ,GAAGvC,KAAK3D,cAAc;gBAAE8D,cAAc;YAAW;QAClE;QAEA,IAAI7D,cAAc2C,IAAI,IAAIzC,oBAAoB;YAC5CqC,OAAO2D,KAAK,GAAGxC,KAAKxD,oBAAoB;gBACtC2D,cAAc;YAChB;QACF;QAEA,OAAOtB;IACT;IAEA,OAAO;QAAE7B;QAAoBC;QAAkBR;IAAiB;AAClE,EAAC"}
1
+ {"version":3,"sources":["../../src/schema/build.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Relation } from 'drizzle-orm'\nimport type {\n ForeignKeyBuilder,\n IndexBuilder,\n PgColumnBuilder,\n PgTableWithColumns,\n UniqueConstraintBuilder,\n} from 'drizzle-orm/pg-core'\nimport type { Field } from 'payload'\n\nimport { createTableName } from '@payloadcms/drizzle'\nimport { relations } from 'drizzle-orm'\nimport {\n foreignKey,\n index,\n integer,\n numeric,\n serial,\n timestamp,\n unique,\n varchar,\n} from 'drizzle-orm/pg-core'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { GenericColumns, GenericTable, IDType, PostgresAdapter } from '../types.js'\n\nimport { parentIDColumnMap } from './parentIDColumnMap.js'\nimport { setColumnID } from './setColumnID.js'\nimport { traverseFields } from './traverseFields.js'\n\nexport type BaseExtraConfig = Record<\n string,\n (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder\n>\n\nexport type RelationMap = Map<string, { localized: boolean; target: string; type: 'many' | 'one' }>\n\ntype Args = {\n adapter: PostgresAdapter\n baseColumns?: Record<string, PgColumnBuilder>\n baseExtraConfig?: BaseExtraConfig\n buildNumbers?: boolean\n buildRelationships?: boolean\n disableNotNull: boolean\n disableUnique: boolean\n fields: Field[]\n rootRelationsToBuild?: RelationMap\n rootRelationships?: Set<string>\n rootTableIDColType?: string\n rootTableName?: string\n tableName: string\n timestamps?: boolean\n versions: boolean\n}\n\ntype Result = {\n hasManyNumberField: 'index' | boolean\n hasManyTextField: 'index' | boolean\n relationsToBuild: RelationMap\n}\n\nexport const buildTable = ({\n adapter,\n baseColumns = {},\n baseExtraConfig = {},\n disableNotNull,\n disableUnique = false,\n fields,\n rootRelationsToBuild,\n rootRelationships,\n rootTableIDColType,\n rootTableName: incomingRootTableName,\n tableName,\n timestamps,\n versions,\n}: Args): Result => {\n const isRoot = !incomingRootTableName\n const rootTableName = incomingRootTableName || tableName\n const columns: Record<string, PgColumnBuilder> = baseColumns\n const indexes: Record<string, (cols: GenericColumns) => IndexBuilder> = {}\n\n const localesColumns: Record<string, PgColumnBuilder> = {}\n const localesIndexes: Record<string, (cols: GenericColumns) => IndexBuilder> = {}\n let localesTable: GenericTable | PgTableWithColumns<any>\n let textsTable: GenericTable | PgTableWithColumns<any>\n let numbersTable: GenericTable | PgTableWithColumns<any>\n\n // Relationships to the base collection\n const relationships: Set<string> = rootRelationships || new Set()\n\n let relationshipsTable: GenericTable | PgTableWithColumns<any>\n\n // Drizzle relations\n const relationsToBuild: RelationMap = new Map()\n\n const idColType: IDType = setColumnID({ adapter, columns, fields })\n\n const {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n } = traverseFields({\n adapter,\n columns,\n disableNotNull,\n disableUnique,\n fields,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: tableName,\n parentTableName: tableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild: rootRelationsToBuild || relationsToBuild,\n rootTableIDColType: rootTableIDColType || idColType,\n rootTableName,\n versions,\n })\n\n // split the relationsToBuild by localized and non-localized\n const localizedRelations = new Map()\n const nonLocalizedRelations = new Map()\n\n relationsToBuild.forEach(({ type, localized, target }, key) => {\n const map = localized ? localizedRelations : nonLocalizedRelations\n map.set(key, { type, target })\n })\n\n if (timestamps) {\n columns.createdAt = timestamp('created_at', {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n .defaultNow()\n .notNull()\n columns.updatedAt = timestamp('updated_at', {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n .defaultNow()\n .notNull()\n }\n\n const table = adapter.pgSchema.table(tableName, columns, (cols) => {\n const extraConfig = Object.entries(baseExtraConfig).reduce((config, [key, func]) => {\n config[key] = func(cols)\n return config\n }, {})\n\n const result = Object.entries(indexes).reduce((acc, [colName, func]) => {\n acc[colName] = func(cols)\n return acc\n }, extraConfig)\n\n return result\n })\n\n adapter.tables[tableName] = table\n\n if (hasLocalizedField || localizedRelations.size) {\n const localeTableName = `${tableName}${adapter.localesSuffix}`\n localesColumns.id = serial('id').primaryKey()\n localesColumns._locale = adapter.enums.enum__locales('_locale').notNull()\n localesColumns._parentID = parentIDColumnMap[idColType]('_parent_id').notNull()\n\n localesTable = adapter.pgSchema.table(localeTableName, localesColumns, (cols) => {\n return Object.entries(localesIndexes).reduce(\n (acc, [colName, func]) => {\n acc[colName] = func(cols)\n return acc\n },\n {\n _localeParent: unique(`${localeTableName}_locale_parent_id_unique`).on(\n cols._locale,\n cols._parentID,\n ),\n _parentIdFk: foreignKey({\n name: `${localeTableName}_parent_id_fk`,\n columns: [cols._parentID],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n },\n )\n })\n\n adapter.tables[localeTableName] = localesTable\n\n adapter.relations[`relations_${localeTableName}`] = relations(localesTable, ({ many, one }) => {\n const result: Record<string, Relation<string>> = {}\n\n result._parentID = one(table, {\n fields: [localesTable._parentID],\n references: [table.id],\n // name the relationship by what the many() relationName is\n relationName: '_locales',\n })\n\n localizedRelations.forEach(({ type, target }, key) => {\n if (type === 'one') {\n result[key] = one(adapter.tables[target], {\n fields: [localesTable[key]],\n references: [adapter.tables[target].id],\n relationName: key,\n })\n }\n if (type === 'many') {\n result[key] = many(adapter.tables[target], {\n relationName: key,\n })\n }\n })\n\n return result\n })\n }\n\n if (isRoot) {\n if (hasManyTextField) {\n const textsTableName = `${rootTableName}_texts`\n const columns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n order: integer('order').notNull(),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n text: varchar('text'),\n }\n\n if (hasLocalizedManyTextField) {\n columns.locale = adapter.enums.enum__locales('locale')\n }\n\n textsTable = adapter.pgSchema.table(textsTableName, columns, (cols) => {\n const config: Record<string, ForeignKeyBuilder | IndexBuilder> = {\n orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent),\n parentFk: foreignKey({\n name: `${textsTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n }\n\n if (hasManyTextField === 'index') {\n config.text_idx = index(`${textsTableName}_text_idx`).on(cols.text)\n }\n\n if (hasLocalizedManyTextField) {\n config.localeParent = index(`${textsTableName}_locale_parent`).on(\n cols.locale,\n cols.parent,\n )\n }\n\n return config\n })\n\n adapter.tables[textsTableName] = textsTable\n\n adapter.relations[`relations_${textsTableName}`] = relations(textsTable, ({ one }) => ({\n parent: one(table, {\n fields: [textsTable.parent],\n references: [table.id],\n relationName: '_texts',\n }),\n }))\n }\n\n if (hasManyNumberField) {\n const numbersTableName = `${rootTableName}_numbers`\n const columns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n number: numeric('number'),\n order: integer('order').notNull(),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n }\n\n if (hasLocalizedManyNumberField) {\n columns.locale = adapter.enums.enum__locales('locale')\n }\n\n numbersTable = adapter.pgSchema.table(numbersTableName, columns, (cols) => {\n const config: Record<string, ForeignKeyBuilder | IndexBuilder> = {\n orderParentIdx: index(`${numbersTableName}_order_parent_idx`).on(cols.order, cols.parent),\n parentFk: foreignKey({\n name: `${numbersTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n }\n\n if (hasManyNumberField === 'index') {\n config.numberIdx = index(`${numbersTableName}_number_idx`).on(cols.number)\n }\n\n if (hasLocalizedManyNumberField) {\n config.localeParent = index(`${numbersTableName}_locale_parent`).on(\n cols.locale,\n cols.parent,\n )\n }\n\n return config\n })\n\n adapter.tables[numbersTableName] = numbersTable\n\n adapter.relations[`relations_${numbersTableName}`] = relations(numbersTable, ({ one }) => ({\n parent: one(table, {\n fields: [numbersTable.parent],\n references: [table.id],\n relationName: '_numbers',\n }),\n }))\n }\n\n if (relationships.size) {\n const relationshipColumns: Record<string, PgColumnBuilder> = {\n id: serial('id').primaryKey(),\n order: integer('order'),\n parent: parentIDColumnMap[idColType]('parent_id').notNull(),\n path: varchar('path').notNull(),\n }\n\n if (hasLocalizedRelationshipField) {\n relationshipColumns.locale = adapter.enums.enum__locales('locale')\n }\n\n const relationExtraConfig: BaseExtraConfig = {}\n const relationshipsTableName = `${tableName}${adapter.relationshipsSuffix}`\n\n relationships.forEach((relationTo) => {\n const relationshipConfig = adapter.payload.collections[relationTo].config\n const formattedRelationTo = createTableName({\n adapter,\n config: relationshipConfig,\n throwValidationError: true,\n })\n let colType = adapter.idType === 'uuid' ? 'uuid' : 'integer'\n const relatedCollectionCustomIDType =\n adapter.payload.collections[relationshipConfig.slug]?.customIDType\n\n if (relatedCollectionCustomIDType === 'number') colType = 'numeric'\n if (relatedCollectionCustomIDType === 'text') colType = 'varchar'\n\n relationshipColumns[`${relationTo}ID`] = parentIDColumnMap[colType](\n `${formattedRelationTo}_id`,\n )\n\n relationExtraConfig[`${relationTo}IdFk`] = (cols) =>\n foreignKey({\n name: `${relationshipsTableName}_${toSnakeCase(relationTo)}_fk`,\n columns: [cols[`${relationTo}ID`]],\n foreignColumns: [adapter.tables[formattedRelationTo].id],\n }).onDelete('cascade')\n })\n\n relationshipsTable = adapter.pgSchema.table(\n relationshipsTableName,\n relationshipColumns,\n (cols) => {\n const result: Record<string, ForeignKeyBuilder | IndexBuilder> = Object.entries(\n relationExtraConfig,\n ).reduce(\n (config, [key, func]) => {\n config[key] = func(cols)\n return config\n },\n {\n order: index(`${relationshipsTableName}_order_idx`).on(cols.order),\n parentFk: foreignKey({\n name: `${relationshipsTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [table.id],\n }).onDelete('cascade'),\n parentIdx: index(`${relationshipsTableName}_parent_idx`).on(cols.parent),\n pathIdx: index(`${relationshipsTableName}_path_idx`).on(cols.path),\n },\n )\n\n if (hasLocalizedRelationshipField) {\n result.localeIdx = index(`${relationshipsTableName}_locale_idx`).on(cols.locale)\n }\n\n return result\n },\n )\n\n adapter.tables[relationshipsTableName] = relationshipsTable\n\n adapter.relations[`relations_${relationshipsTableName}`] = relations(\n relationshipsTable,\n ({ one }) => {\n const result: Record<string, Relation<string>> = {\n parent: one(table, {\n fields: [relationshipsTable.parent],\n references: [table.id],\n relationName: '_rels',\n }),\n }\n\n relationships.forEach((relationTo) => {\n const relatedTableName = createTableName({\n adapter,\n config: adapter.payload.collections[relationTo].config,\n throwValidationError: true,\n })\n const idColumnName = `${relationTo}ID`\n result[idColumnName] = one(adapter.tables[relatedTableName], {\n fields: [relationshipsTable[idColumnName]],\n references: [adapter.tables[relatedTableName].id],\n relationName: relationTo,\n })\n })\n\n return result\n },\n )\n }\n }\n\n adapter.relations[`relations_${tableName}`] = relations(table, ({ many, one }) => {\n const result: Record<string, Relation<string>> = {}\n\n nonLocalizedRelations.forEach(({ type, target }, key) => {\n if (type === 'one') {\n result[key] = one(adapter.tables[target], {\n fields: [table[key]],\n references: [adapter.tables[target].id],\n relationName: key,\n })\n }\n if (type === 'many') {\n result[key] = many(adapter.tables[target], { relationName: key })\n }\n })\n\n if (hasLocalizedField) {\n result._locales = many(localesTable, { relationName: '_locales' })\n }\n\n if (hasManyTextField) {\n result._texts = many(textsTable, { relationName: '_texts' })\n }\n\n if (hasManyNumberField) {\n result._numbers = many(numbersTable, { relationName: '_numbers' })\n }\n\n if (relationships.size && relationshipsTable) {\n result._rels = many(relationshipsTable, {\n relationName: '_rels',\n })\n }\n\n return result\n })\n\n return { hasManyNumberField, hasManyTextField, relationsToBuild }\n}\n"],"names":["createTableName","relations","foreignKey","index","integer","numeric","serial","timestamp","unique","varchar","toSnakeCase","parentIDColumnMap","setColumnID","traverseFields","buildTable","adapter","baseColumns","baseExtraConfig","disableNotNull","disableUnique","fields","rootRelationsToBuild","rootRelationships","rootTableIDColType","rootTableName","incomingRootTableName","tableName","timestamps","versions","isRoot","columns","indexes","localesColumns","localesIndexes","localesTable","textsTable","numbersTable","relationships","Set","relationshipsTable","relationsToBuild","Map","idColType","hasLocalizedField","hasLocalizedManyNumberField","hasLocalizedManyTextField","hasLocalizedRelationshipField","hasManyNumberField","hasManyTextField","newTableName","parentTableName","localizedRelations","nonLocalizedRelations","forEach","type","localized","target","key","map","set","createdAt","mode","precision","withTimezone","defaultNow","notNull","updatedAt","table","pgSchema","cols","extraConfig","Object","entries","reduce","config","func","result","acc","colName","tables","size","localeTableName","localesSuffix","id","primaryKey","_locale","enums","enum__locales","_parentID","_localeParent","on","_parentIdFk","name","foreignColumns","onDelete","many","one","references","relationName","textsTableName","order","parent","path","text","locale","orderParentIdx","parentFk","text_idx","localeParent","numbersTableName","number","numberIdx","relationshipColumns","relationExtraConfig","relationshipsTableName","relationshipsSuffix","relationTo","relationshipConfig","payload","collections","formattedRelationTo","throwValidationError","colType","idType","relatedCollectionCustomIDType","slug","customIDType","parentIdx","pathIdx","localeIdx","relatedTableName","idColumnName","_locales","_texts","_numbers","_rels"],"mappings":"AAAA,oCAAoC,GAWpC,SAASA,eAAe,QAAQ,sBAAqB;AACrD,SAASC,SAAS,QAAQ,cAAa;AACv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IAEA,OAAO;QAAE7B;QAAoBC;QAAkBR;IAAiB;AAClE,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/createIndex.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport { index, uniqueIndex } from 'drizzle-orm/pg-core'\n\nimport type { GenericColumn } from '../types.js'\n\ntype CreateIndexArgs = {\n columnName: string\n name: string | string[]\n tableName: string\n unique?: boolean\n}\n\nexport const createIndex = ({ name, columnName, tableName, unique }: CreateIndexArgs) => {\n return (table: { [x: string]: GenericColumn }) => {\n let columns\n if (Array.isArray(name)) {\n columns = name\n .map((columnName) => table[columnName])\n // exclude fields were included in compound indexes but do not exist on the table\n .filter((col) => typeof col !== 'undefined')\n } else {\n columns = [table[name]]\n }\n if (unique)\n return uniqueIndex(`${tableName}_${columnName}_idx`).on(columns[0], ...columns.slice(1))\n return index(`${tableName}_${columnName}_idx`).on(columns[0], ...columns.slice(1))\n }\n}\n"],"names":["index","uniqueIndex","createIndex","name","columnName","tableName","unique","table","columns","Array","isArray","map","filter","col","on","slice"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GACpC,SAASA,KAAK,EAAEC,WAAW,QAAQ,sBAAqB;AAWxD,OAAO,MAAMC,cAAc,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAEC,SAAS,EAAEC,MAAM,EAAmB;IAClF,OAAO,CAACC;QACN,IAAIC;QACJ,IAAIC,MAAMC,OAAO,CAACP,OAAO;YACvBK,UAAUL,KACPQ,GAAG,CAAC,CAACP,aAAeG,KAAK,CAACH,WAAW,CACtC,iFAAiF;aAChFQ,MAAM,CAAC,CAACC,MAAQ,OAAOA,QAAQ;QACpC,OAAO;YACLL,UAAU;gBAACD,KAAK,CAACJ,KAAK;aAAC;QACzB;QACA,IAAIG,QACF,OAAOL,YAAY,CAAC,EAAEI,UAAU,CAAC,EAAED,WAAW,IAAI,CAAC,EAAEU,EAAE,CAACN,OAAO,CAAC,EAAE,KAAKA,QAAQO,KAAK,CAAC;QACvF,OAAOf,MAAM,CAAC,EAAEK,UAAU,CAAC,EAAED,WAAW,IAAI,CAAC,EAAEU,EAAE,CAACN,OAAO,CAAC,EAAE,KAAKA,QAAQO,KAAK,CAAC;IACjF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/schema/createIndex.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport { index, uniqueIndex } from 'drizzle-orm/pg-core'\n\nimport type { GenericColumn } from '../types.js'\n\ntype CreateIndexArgs = {\n columnName: string\n name: string | string[]\n tableName: string\n unique?: boolean\n}\n\nexport const createIndex = ({ name, columnName, tableName, unique }: CreateIndexArgs) => {\n return (table: { [x: string]: GenericColumn }) => {\n let columns\n if (Array.isArray(name)) {\n columns = name\n .map((columnName) => table[columnName])\n // exclude fields were included in compound indexes but do not exist on the table\n .filter((col) => typeof col !== 'undefined')\n } else {\n columns = [table[name]]\n }\n if (unique)\n return uniqueIndex(`${tableName}_${columnName}_idx`).on(columns[0], ...columns.slice(1))\n return index(`${tableName}_${columnName}_idx`).on(columns[0], ...columns.slice(1))\n }\n}\n"],"names":["index","uniqueIndex","createIndex","name","columnName","tableName","unique","table","columns","Array","isArray","map","filter","col","on","slice"],"mappings":"AAAA,oCAAoC,GACpC,SAASA,KAAK,EAAEC,WAAW,QAAQ,sBAAqB;AAWxD,OAAO,MAAMC,cAAc,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAEC,SAAS,EAAEC,MAAM,EAAmB;IAClF,OAAO,CAACC;QACN,IAAIC;QACJ,IAAIC,MAAMC,OAAO,CAACP,OAAO;YACvBK,UAAUL,KACPQ,GAAG,CAAC,CAACP,aAAeG,KAAK,CAACH,WAAW,CACtC,iFAAiF;aAChFQ,MAAM,CAAC,CAACC,MAAQ,OAAOA,QAAQ;QACpC,OAAO;YACLL,UAAU;gBAACD,KAAK,CAACJ,KAAK;aAAC;QACzB;QACA,IAAIG,QACF,OAAOL,YAAY,CAAC,EAAEI,UAAU,CAAC,EAAED,WAAW,IAAI,CAAC,EAAEU,EAAE,CAACN,OAAO,CAAC,EAAE,KAAKA,QAAQO,KAAK,CAAC;QACvF,OAAOf,MAAM,CAAC,EAAEK,UAAU,CAAC,EAAED,WAAW,IAAI,CAAC,EAAEU,EAAE,CAACN,OAAO,CAAC,EAAE,KAAKA,QAAQO,KAAK,CAAC;IACjF;AACF,EAAC"}
@@ -1,3 +1,3 @@
1
- import type { Field } from 'payload/types';
1
+ import type { Field } from 'payload';
2
2
  export declare const idToUUID: (fields: Field[]) => Field[];
3
3
  //# sourceMappingURL=idToUUID.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"idToUUID.d.ts","sourceRoot":"","sources":["../../src/schema/idToUUID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,eAAO,MAAM,QAAQ,WAAY,KAAK,EAAE,KAAG,KAAK,EAU5C,CAAA"}
1
+ {"version":3,"file":"idToUUID.d.ts","sourceRoot":"","sources":["../../src/schema/idToUUID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,eAAO,MAAM,QAAQ,WAAY,KAAK,EAAE,KAAG,KAAK,EAU5C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/idToUUID.ts"],"sourcesContent":["import type { Field } from 'payload/types'\n\nexport const idToUUID = (fields: Field[]): Field[] =>\n fields.map((field) => {\n if ('name' in field && field.name === 'id') {\n return {\n ...field,\n name: '_uuid',\n }\n }\n\n return field\n })\n"],"names":["idToUUID","fields","map","field","name"],"rangeMappings":";;;;;;;;","mappings":"AAEA,OAAO,MAAMA,WAAW,CAACC,SACvBA,OAAOC,GAAG,CAAC,CAACC;QACV,IAAI,UAAUA,SAASA,MAAMC,IAAI,KAAK,MAAM;YAC1C,OAAO;gBACL,GAAGD,KAAK;gBACRC,MAAM;YACR;QACF;QAEA,OAAOD;IACT,GAAE"}
1
+ {"version":3,"sources":["../../src/schema/idToUUID.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nexport const idToUUID = (fields: Field[]): Field[] =>\n fields.map((field) => {\n if ('name' in field && field.name === 'id') {\n return {\n ...field,\n name: '_uuid',\n }\n }\n\n return field\n })\n"],"names":["idToUUID","fields","map","field","name"],"mappings":"AAEA,OAAO,MAAMA,WAAW,CAACC,SACvBA,OAAOC,GAAG,CAAC,CAACC;QACV,IAAI,UAAUA,SAASA,MAAMC,IAAI,KAAK,MAAM;YAC1C,OAAO;gBACL,GAAGD,KAAK;gBACRC,MAAM;YACR;QACF;QAEA,OAAOD;IACT,GAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/parentIDColumnMap.ts"],"sourcesContent":["import { integer, numeric, uuid, varchar } from 'drizzle-orm/pg-core'\n\nimport type { IDType } from '../types.js'\n\nexport const parentIDColumnMap: Record<\n IDType,\n typeof integer<string> | typeof numeric<string> | typeof uuid<string> | typeof varchar\n> = {\n integer,\n numeric,\n uuid,\n varchar,\n}\n"],"names":["integer","numeric","uuid","varchar","parentIDColumnMap"],"rangeMappings":";;;;;;","mappings":"AAAA,SAASA,OAAO,EAAEC,OAAO,EAAEC,IAAI,EAAEC,OAAO,QAAQ,sBAAqB;AAIrE,OAAO,MAAMC,oBAGT;IACFJ;IACAC;IACAC;IACAC;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/schema/parentIDColumnMap.ts"],"sourcesContent":["import { integer, numeric, uuid, varchar } from 'drizzle-orm/pg-core'\n\nimport type { IDType } from '../types.js'\n\nexport const parentIDColumnMap: Record<\n IDType,\n typeof integer<string> | typeof numeric<string> | typeof uuid<string> | typeof varchar\n> = {\n integer,\n numeric,\n uuid,\n varchar,\n}\n"],"names":["integer","numeric","uuid","varchar","parentIDColumnMap"],"mappings":"AAAA,SAASA,OAAO,EAAEC,OAAO,EAAEC,IAAI,EAAEC,OAAO,QAAQ,sBAAqB;AAIrE,OAAO,MAAMC,oBAGT;IACFJ;IACAC;IACAC;IACAC;AACF,EAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { PgColumnBuilder } from 'drizzle-orm/pg-core';
2
- import { type Field } from 'payload/types';
2
+ import { type Field } from 'payload';
3
3
  import type { IDType, PostgresAdapter } from '../types.js';
4
4
  type Args = {
5
5
  adapter: PostgresAdapter;
@@ -1 +1 @@
1
- {"version":3,"file":"setColumnID.d.ts","sourceRoot":"","sources":["../../src/schema/setColumnID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAG1D,OAAO,EAAE,KAAK,KAAK,EAAoB,MAAM,eAAe,CAAA;AAG5D,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE1D,KAAK,IAAI,GAAG;IAAE,OAAO,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CAAE,CAAA;AACnG,eAAO,MAAM,WAAW,iCAAkC,IAAI,KAAG,MAuBhE,CAAA"}
1
+ {"version":3,"file":"setColumnID.d.ts","sourceRoot":"","sources":["../../src/schema/setColumnID.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAG1D,OAAO,EAAE,KAAK,KAAK,EAAyB,MAAM,SAAS,CAAA;AAG3D,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE1D,KAAK,IAAI,GAAG;IAAE,OAAO,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CAAE,CAAA;AACnG,eAAO,MAAM,WAAW,iCAAkC,IAAI,KAAG,MAuBhE,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { numeric, serial, uuid, varchar } from 'drizzle-orm/pg-core';
2
- import { fieldAffectsData } from 'payload/types';
3
- import { flattenTopLevelFields } from 'payload/utilities';
2
+ import { flattenTopLevelFields } from 'payload';
3
+ import { fieldAffectsData } from 'payload/shared';
4
4
  export const setColumnID = ({ adapter, columns, fields })=>{
5
5
  const idField = flattenTopLevelFields(fields).find((field)=>fieldAffectsData(field) && field.name === 'id');
6
6
  if (idField) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/setColumnID.ts"],"sourcesContent":["import type { PgColumnBuilder } from 'drizzle-orm/pg-core'\n\nimport { numeric, serial, uuid, varchar } from 'drizzle-orm/pg-core'\nimport { type Field, fieldAffectsData } from 'payload/types'\nimport { flattenTopLevelFields } from 'payload/utilities'\n\nimport type { IDType, PostgresAdapter } from '../types.js'\n\ntype Args = { adapter: PostgresAdapter; columns: Record<string, PgColumnBuilder>; fields: Field[] }\nexport const setColumnID = ({ adapter, columns, fields }: Args): IDType => {\n const idField = flattenTopLevelFields(fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n if (idField) {\n if (idField.type === 'number') {\n columns.id = numeric('id').primaryKey()\n return 'numeric'\n }\n\n if (idField.type === 'text') {\n columns.id = varchar('id').primaryKey()\n return 'varchar'\n }\n }\n\n if (adapter.idType === 'uuid') {\n columns.id = uuid('id').defaultRandom().primaryKey()\n return 'uuid'\n }\n\n columns.id = serial('id').primaryKey()\n return 'integer'\n}\n"],"names":["numeric","serial","uuid","varchar","fieldAffectsData","flattenTopLevelFields","setColumnID","adapter","columns","fields","idField","find","field","name","type","id","primaryKey","idType","defaultRandom"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,QAAQ,sBAAqB;AACpE,SAAqBC,gBAAgB,QAAQ,gBAAe;AAC5D,SAASC,qBAAqB,QAAQ,oBAAmB;AAKzD,OAAO,MAAMC,cAAc,CAAC,EAAEC,OAAO,EAAEC,OAAO,EAAEC,MAAM,EAAQ;IAC5D,MAAMC,UAAUL,sBAAsBI,QAAQE,IAAI,CAChD,CAACC,QAAUR,iBAAiBQ,UAAUA,MAAMC,IAAI,KAAK;IAEvD,IAAIH,SAAS;QACX,IAAIA,QAAQI,IAAI,KAAK,UAAU;YAC7BN,QAAQO,EAAE,GAAGf,QAAQ,MAAMgB,UAAU;YACrC,OAAO;QACT;QAEA,IAAIN,QAAQI,IAAI,KAAK,QAAQ;YAC3BN,QAAQO,EAAE,GAAGZ,QAAQ,MAAMa,UAAU;YACrC,OAAO;QACT;IACF;IAEA,IAAIT,QAAQU,MAAM,KAAK,QAAQ;QAC7BT,QAAQO,EAAE,GAAGb,KAAK,MAAMgB,aAAa,GAAGF,UAAU;QAClD,OAAO;IACT;IAEAR,QAAQO,EAAE,GAAGd,OAAO,MAAMe,UAAU;IACpC,OAAO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/schema/setColumnID.ts"],"sourcesContent":["import type { PgColumnBuilder } from 'drizzle-orm/pg-core'\n\nimport { numeric, serial, uuid, varchar } from 'drizzle-orm/pg-core'\nimport { type Field, flattenTopLevelFields } from 'payload'\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { IDType, PostgresAdapter } from '../types.js'\n\ntype Args = { adapter: PostgresAdapter; columns: Record<string, PgColumnBuilder>; fields: Field[] }\nexport const setColumnID = ({ adapter, columns, fields }: Args): IDType => {\n const idField = flattenTopLevelFields(fields).find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n if (idField) {\n if (idField.type === 'number') {\n columns.id = numeric('id').primaryKey()\n return 'numeric'\n }\n\n if (idField.type === 'text') {\n columns.id = varchar('id').primaryKey()\n return 'varchar'\n }\n }\n\n if (adapter.idType === 'uuid') {\n columns.id = uuid('id').defaultRandom().primaryKey()\n return 'uuid'\n }\n\n columns.id = serial('id').primaryKey()\n return 'integer'\n}\n"],"names":["numeric","serial","uuid","varchar","flattenTopLevelFields","fieldAffectsData","setColumnID","adapter","columns","fields","idField","find","field","name","type","id","primaryKey","idType","defaultRandom"],"mappings":"AAEA,SAASA,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAEC,OAAO,QAAQ,sBAAqB;AACpE,SAAqBC,qBAAqB,QAAQ,UAAS;AAC3D,SAASC,gBAAgB,QAAQ,iBAAgB;AAKjD,OAAO,MAAMC,cAAc,CAAC,EAAEC,OAAO,EAAEC,OAAO,EAAEC,MAAM,EAAQ;IAC5D,MAAMC,UAAUN,sBAAsBK,QAAQE,IAAI,CAChD,CAACC,QAAUP,iBAAiBO,UAAUA,MAAMC,IAAI,KAAK;IAEvD,IAAIH,SAAS;QACX,IAAIA,QAAQI,IAAI,KAAK,UAAU;YAC7BN,QAAQO,EAAE,GAAGf,QAAQ,MAAMgB,UAAU;YACrC,OAAO;QACT;QAEA,IAAIN,QAAQI,IAAI,KAAK,QAAQ;YAC3BN,QAAQO,EAAE,GAAGZ,QAAQ,MAAMa,UAAU;YACrC,OAAO;QACT;IACF;IAEA,IAAIT,QAAQU,MAAM,KAAK,QAAQ;QAC7BT,QAAQO,EAAE,GAAGb,KAAK,MAAMgB,aAAa,GAAGF,UAAU;QAClD,OAAO;IACT;IAEAR,QAAQO,EAAE,GAAGd,OAAO,MAAMe,UAAU;IACpC,OAAO;AACT,EAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { IndexBuilder, PgColumnBuilder } from 'drizzle-orm/pg-core';
2
- import type { Field, TabAsField } from 'payload/types';
2
+ import type { Field, TabAsField } from 'payload';
3
3
  import type { GenericColumns, PostgresAdapter } from '../types.js';
4
4
  import type { RelationMap } from './build.js';
5
5
  type Args = {
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/schema/traverseFields.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,UAA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