@payloadcms/db-postgres 3.0.0-canary.f6e77b8 → 3.0.0-canary.fb04843

Sign up to get free protection for your applications and to get access to all the features.
Files changed (370) 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 +45 -17
  5. package/dist/connect.js.map +1 -1
  6. package/dist/exports/migration-utils.d.ts +2 -0
  7. package/dist/exports/migration-utils.d.ts.map +1 -0
  8. package/dist/exports/migration-utils.js +3 -0
  9. package/dist/exports/migration-utils.js.map +1 -0
  10. package/dist/index.d.ts +3 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +66 -69
  13. package/dist/index.js.map +1 -1
  14. package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
  15. package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
  16. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
  17. package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
  18. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +20 -0
  19. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
  20. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +169 -0
  21. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
  22. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
  23. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
  24. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +196 -0
  25. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
  26. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
  27. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
  28. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
  29. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
  30. package/dist/predefinedMigrations/v2-v3/index.d.ts +23 -0
  31. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
  32. package/dist/predefinedMigrations/v2-v3/index.js +211 -0
  33. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
  34. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +20 -0
  35. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
  36. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +63 -0
  37. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
  38. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +23 -0
  39. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
  40. package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
  41. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
  42. package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
  43. package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
  44. package/dist/predefinedMigrations/v2-v3/types.js +6 -0
  45. package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
  46. package/dist/types.d.ts +65 -77
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/types.js.map +1 -1
  49. package/license.md +22 -0
  50. package/package.json +35 -17
  51. package/dist/count.d.ts +0 -3
  52. package/dist/count.d.ts.map +0 -1
  53. package/dist/count.js +0 -50
  54. package/dist/count.js.map +0 -1
  55. package/dist/create.d.ts +0 -3
  56. package/dist/create.d.ts.map +0 -1
  57. package/dist/create.js +0 -19
  58. package/dist/create.js.map +0 -1
  59. package/dist/createGlobal.d.ts +0 -5
  60. package/dist/createGlobal.d.ts.map +0 -1
  61. package/dist/createGlobal.js +0 -19
  62. package/dist/createGlobal.js.map +0 -1
  63. package/dist/createGlobalVersion.d.ts +0 -6
  64. package/dist/createGlobalVersion.d.ts.map +0 -1
  65. package/dist/createGlobalVersion.js +0 -33
  66. package/dist/createGlobalVersion.js.map +0 -1
  67. package/dist/createMigration.d.ts +0 -3
  68. package/dist/createMigration.d.ts.map +0 -1
  69. package/dist/createMigration.js +0 -81
  70. package/dist/createMigration.js.map +0 -1
  71. package/dist/createVersion.d.ts +0 -5
  72. package/dist/createVersion.d.ts.map +0 -1
  73. package/dist/createVersion.js +0 -44
  74. package/dist/createVersion.js.map +0 -1
  75. package/dist/deleteMany.d.ts +0 -3
  76. package/dist/deleteMany.d.ts.map +0 -1
  77. package/dist/deleteMany.js +0 -28
  78. package/dist/deleteMany.js.map +0 -1
  79. package/dist/deleteOne.d.ts +0 -3
  80. package/dist/deleteOne.d.ts.map +0 -1
  81. package/dist/deleteOne.js +0 -59
  82. package/dist/deleteOne.js.map +0 -1
  83. package/dist/deleteVersions.d.ts +0 -3
  84. package/dist/deleteVersions.d.ts.map +0 -1
  85. package/dist/deleteVersions.js +0 -31
  86. package/dist/deleteVersions.js.map +0 -1
  87. package/dist/destroy.d.ts +0 -3
  88. package/dist/destroy.d.ts.map +0 -1
  89. package/dist/destroy.js +0 -11
  90. package/dist/destroy.js.map +0 -1
  91. package/dist/find/buildFindManyArgs.d.ts +0 -13
  92. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  93. package/dist/find/buildFindManyArgs.js +0 -64
  94. package/dist/find/buildFindManyArgs.js.map +0 -1
  95. package/dist/find/chainMethods.d.ts +0 -16
  96. package/dist/find/chainMethods.d.ts.map +0 -1
  97. package/dist/find/chainMethods.js +0 -12
  98. package/dist/find/chainMethods.js.map +0 -1
  99. package/dist/find/findMany.d.ts +0 -22
  100. package/dist/find/findMany.d.ts.map +0 -1
  101. package/dist/find/findMany.js +0 -163
  102. package/dist/find/findMany.js.map +0 -1
  103. package/dist/find/traverseFields.d.ts +0 -16
  104. package/dist/find/traverseFields.d.ts.map +0 -1
  105. package/dist/find/traverseFields.js +0 -138
  106. package/dist/find/traverseFields.js.map +0 -1
  107. package/dist/find.d.ts +0 -3
  108. package/dist/find.d.ts.map +0 -1
  109. package/dist/find.js +0 -21
  110. package/dist/find.js.map +0 -1
  111. package/dist/findGlobal.d.ts +0 -3
  112. package/dist/findGlobal.d.ts.map +0 -1
  113. package/dist/findGlobal.js +0 -23
  114. package/dist/findGlobal.js.map +0 -1
  115. package/dist/findGlobalVersions.d.ts +0 -3
  116. package/dist/findGlobalVersions.d.ts.map +0 -1
  117. package/dist/findGlobalVersions.js +0 -24
  118. package/dist/findGlobalVersions.js.map +0 -1
  119. package/dist/findOne.d.ts +0 -5
  120. package/dist/findOne.d.ts.map +0 -1
  121. package/dist/findOne.js +0 -21
  122. package/dist/findOne.js.map +0 -1
  123. package/dist/findVersions.d.ts +0 -3
  124. package/dist/findVersions.d.ts.map +0 -1
  125. package/dist/findVersions.js +0 -24
  126. package/dist/findVersions.js.map +0 -1
  127. package/dist/init.d.ts +0 -3
  128. package/dist/init.d.ts.map +0 -1
  129. package/dist/init.js +0 -96
  130. package/dist/init.js.map +0 -1
  131. package/dist/migrate.d.ts +0 -3
  132. package/dist/migrate.d.ts.map +0 -1
  133. package/dist/migrate.js +0 -99
  134. package/dist/migrate.js.map +0 -1
  135. package/dist/migrateDown.d.ts +0 -3
  136. package/dist/migrateDown.d.ts.map +0 -1
  137. package/dist/migrateDown.js +0 -63
  138. package/dist/migrateDown.js.map +0 -1
  139. package/dist/migrateFresh.d.ts +0 -8
  140. package/dist/migrateFresh.d.ts.map +0 -1
  141. package/dist/migrateFresh.js +0 -72
  142. package/dist/migrateFresh.js.map +0 -1
  143. package/dist/migrateRefresh.d.ts +0 -6
  144. package/dist/migrateRefresh.d.ts.map +0 -1
  145. package/dist/migrateRefresh.js +0 -102
  146. package/dist/migrateRefresh.js.map +0 -1
  147. package/dist/migrateReset.d.ts +0 -6
  148. package/dist/migrateReset.d.ts.map +0 -1
  149. package/dist/migrateReset.js +0 -82
  150. package/dist/migrateReset.js.map +0 -1
  151. package/dist/migrateStatus.d.ts +0 -3
  152. package/dist/migrateStatus.d.ts.map +0 -1
  153. package/dist/migrateStatus.js +0 -44
  154. package/dist/migrateStatus.js.map +0 -1
  155. package/dist/queries/buildAndOrConditions.d.ts +0 -17
  156. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  157. package/dist/queries/buildAndOrConditions.js +0 -29
  158. package/dist/queries/buildAndOrConditions.js.map +0 -1
  159. package/dist/queries/buildQuery.d.ts +0 -31
  160. package/dist/queries/buildQuery.d.ts.map +0 -1
  161. package/dist/queries/buildQuery.js +0 -76
  162. package/dist/queries/buildQuery.js.map +0 -1
  163. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
  164. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  165. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +0 -14
  166. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  167. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
  168. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  169. package/dist/queries/createJSONQuery/formatJSONPathSegment.js +0 -5
  170. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  171. package/dist/queries/createJSONQuery/index.d.ts +0 -10
  172. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  173. package/dist/queries/createJSONQuery/index.js +0 -54
  174. package/dist/queries/createJSONQuery/index.js.map +0 -1
  175. package/dist/queries/getTableColumnFromPath.d.ts +0 -51
  176. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  177. package/dist/queries/getTableColumnFromPath.js +0 -445
  178. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  179. package/dist/queries/operatorMap.d.ts +0 -18
  180. package/dist/queries/operatorMap.d.ts.map +0 -1
  181. package/dist/queries/operatorMap.js +0 -24
  182. package/dist/queries/operatorMap.js.map +0 -1
  183. package/dist/queries/parseParams.d.ts +0 -17
  184. package/dist/queries/parseParams.d.ts.map +0 -1
  185. package/dist/queries/parseParams.js +0 -182
  186. package/dist/queries/parseParams.js.map +0 -1
  187. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  188. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  189. package/dist/queries/sanitizeQueryValue.js +0 -90
  190. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  191. package/dist/queries/selectDistinct.d.ts +0 -23
  192. package/dist/queries/selectDistinct.d.ts.map +0 -1
  193. package/dist/queries/selectDistinct.js +0 -41
  194. package/dist/queries/selectDistinct.js.map +0 -1
  195. package/dist/queryDrafts.d.ts +0 -3
  196. package/dist/queryDrafts.d.ts.map +0 -1
  197. package/dist/queryDrafts.js +0 -41
  198. package/dist/queryDrafts.js.map +0 -1
  199. package/dist/schema/build.d.ts +0 -30
  200. package/dist/schema/build.d.ts.map +0 -1
  201. package/dist/schema/build.js +0 -320
  202. package/dist/schema/build.js.map +0 -1
  203. package/dist/schema/createIndex.d.ts +0 -12
  204. package/dist/schema/createIndex.d.ts.map +0 -1
  205. package/dist/schema/createIndex.js +0 -18
  206. package/dist/schema/createIndex.js.map +0 -1
  207. package/dist/schema/createTableName.d.ts +0 -30
  208. package/dist/schema/createTableName.d.ts.map +0 -1
  209. package/dist/schema/createTableName.js +0 -31
  210. package/dist/schema/createTableName.js.map +0 -1
  211. package/dist/schema/idToUUID.d.ts +0 -3
  212. package/dist/schema/idToUUID.d.ts.map +0 -1
  213. package/dist/schema/idToUUID.js +0 -11
  214. package/dist/schema/idToUUID.js.map +0 -1
  215. package/dist/schema/parentIDColumnMap.d.ts +0 -4
  216. package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
  217. package/dist/schema/parentIDColumnMap.js +0 -9
  218. package/dist/schema/parentIDColumnMap.js.map +0 -1
  219. package/dist/schema/setColumnID.d.ts +0 -11
  220. package/dist/schema/setColumnID.d.ts.map +0 -1
  221. package/dist/schema/setColumnID.js +0 -24
  222. package/dist/schema/setColumnID.js.map +0 -1
  223. package/dist/schema/traverseFields.d.ts +0 -38
  224. package/dist/schema/traverseFields.d.ts.map +0 -1
  225. package/dist/schema/traverseFields.js +0 -551
  226. package/dist/schema/traverseFields.js.map +0 -1
  227. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
  228. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  229. package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
  230. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  231. package/dist/transactions/beginTransaction.d.ts +0 -3
  232. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  233. package/dist/transactions/beginTransaction.js +0 -47
  234. package/dist/transactions/beginTransaction.js.map +0 -1
  235. package/dist/transactions/commitTransaction.d.ts +0 -3
  236. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  237. package/dist/transactions/commitTransaction.js +0 -14
  238. package/dist/transactions/commitTransaction.js.map +0 -1
  239. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  240. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  241. package/dist/transactions/rollbackTransaction.js +0 -13
  242. package/dist/transactions/rollbackTransaction.js.map +0 -1
  243. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  244. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  245. package/dist/transform/read/hasManyNumber.js +0 -10
  246. package/dist/transform/read/hasManyNumber.js.map +0 -1
  247. package/dist/transform/read/hasManyText.d.ts +0 -10
  248. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  249. package/dist/transform/read/hasManyText.js +0 -10
  250. package/dist/transform/read/hasManyText.js.map +0 -1
  251. package/dist/transform/read/index.d.ts +0 -12
  252. package/dist/transform/read/index.d.ts.map +0 -1
  253. package/dist/transform/read/index.js +0 -43
  254. package/dist/transform/read/index.js.map +0 -1
  255. package/dist/transform/read/relationship.d.ts +0 -10
  256. package/dist/transform/read/relationship.d.ts.map +0 -1
  257. package/dist/transform/read/relationship.js +0 -64
  258. package/dist/transform/read/relationship.js.map +0 -1
  259. package/dist/transform/read/traverseFields.d.ts +0 -52
  260. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  261. package/dist/transform/read/traverseFields.js +0 -421
  262. package/dist/transform/read/traverseFields.js.map +0 -1
  263. package/dist/transform/write/array.d.ts +0 -26
  264. package/dist/transform/write/array.d.ts.map +0 -1
  265. package/dist/transform/write/array.js +0 -58
  266. package/dist/transform/write/array.js.map +0 -1
  267. package/dist/transform/write/blocks.d.ts +0 -25
  268. package/dist/transform/write/blocks.d.ts.map +0 -1
  269. package/dist/transform/write/blocks.js +0 -54
  270. package/dist/transform/write/blocks.js.map +0 -1
  271. package/dist/transform/write/index.d.ts +0 -13
  272. package/dist/transform/write/index.d.ts.map +0 -1
  273. package/dist/transform/write/index.js +0 -41
  274. package/dist/transform/write/index.js.map +0 -1
  275. package/dist/transform/write/numbers.d.ts +0 -8
  276. package/dist/transform/write/numbers.d.ts.map +0 -1
  277. package/dist/transform/write/numbers.js +0 -11
  278. package/dist/transform/write/numbers.js.map +0 -1
  279. package/dist/transform/write/relationships.d.ts +0 -10
  280. package/dist/transform/write/relationships.d.ts.map +0 -1
  281. package/dist/transform/write/relationships.js +0 -23
  282. package/dist/transform/write/relationships.js.map +0 -1
  283. package/dist/transform/write/selects.d.ts +0 -8
  284. package/dist/transform/write/selects.d.ts.map +0 -1
  285. package/dist/transform/write/selects.js +0 -20
  286. package/dist/transform/write/selects.js.map +0 -1
  287. package/dist/transform/write/texts.d.ts +0 -8
  288. package/dist/transform/write/texts.d.ts.map +0 -1
  289. package/dist/transform/write/texts.js +0 -11
  290. package/dist/transform/write/texts.js.map +0 -1
  291. package/dist/transform/write/traverseFields.d.ts +0 -50
  292. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  293. package/dist/transform/write/traverseFields.js +0 -428
  294. package/dist/transform/write/traverseFields.js.map +0 -1
  295. package/dist/transform/write/types.d.ts +0 -43
  296. package/dist/transform/write/types.d.ts.map +0 -1
  297. package/dist/transform/write/types.js +0 -3
  298. package/dist/transform/write/types.js.map +0 -1
  299. package/dist/update.d.ts +0 -3
  300. package/dist/update.d.ts.map +0 -1
  301. package/dist/update.js +0 -55
  302. package/dist/update.js.map +0 -1
  303. package/dist/updateGlobal.d.ts +0 -5
  304. package/dist/updateGlobal.d.ts.map +0 -1
  305. package/dist/updateGlobal.js +0 -25
  306. package/dist/updateGlobal.js.map +0 -1
  307. package/dist/updateGlobalVersion.d.ts +0 -5
  308. package/dist/updateGlobalVersion.d.ts.map +0 -1
  309. package/dist/updateGlobalVersion.js +0 -36
  310. package/dist/updateGlobalVersion.js.map +0 -1
  311. package/dist/updateVersion.d.ts +0 -5
  312. package/dist/updateVersion.d.ts.map +0 -1
  313. package/dist/updateVersion.js +0 -36
  314. package/dist/updateVersion.js.map +0 -1
  315. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  316. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  317. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  318. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  319. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  320. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  321. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  322. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  323. package/dist/upsertRow/index.d.ts +0 -4
  324. package/dist/upsertRow/index.d.ts.map +0 -1
  325. package/dist/upsertRow/index.js +0 -277
  326. package/dist/upsertRow/index.js.map +0 -1
  327. package/dist/upsertRow/insertArrays.d.ts +0 -13
  328. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  329. package/dist/upsertRow/insertArrays.js +0 -68
  330. package/dist/upsertRow/insertArrays.js.map +0 -1
  331. package/dist/upsertRow/types.d.ts +0 -27
  332. package/dist/upsertRow/types.d.ts.map +0 -1
  333. package/dist/upsertRow/types.js +0 -3
  334. package/dist/upsertRow/types.js.map +0 -1
  335. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  336. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  337. package/dist/utilities/appendPrefixToKeys.js +0 -6
  338. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  339. package/dist/utilities/createBlocksMap.d.ts +0 -5
  340. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  341. package/dist/utilities/createBlocksMap.js +0 -29
  342. package/dist/utilities/createBlocksMap.js.map +0 -1
  343. package/dist/utilities/createMigrationTable.d.ts +0 -3
  344. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  345. package/dist/utilities/createMigrationTable.js +0 -13
  346. package/dist/utilities/createMigrationTable.js.map +0 -1
  347. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  348. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  349. package/dist/utilities/createRelationshipMap.js +0 -19
  350. package/dist/utilities/createRelationshipMap.js.map +0 -1
  351. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  352. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  353. package/dist/utilities/hasLocalesTable.js +0 -11
  354. package/dist/utilities/hasLocalesTable.js.map +0 -1
  355. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  356. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  357. package/dist/utilities/isArrayOfRows.js +0 -5
  358. package/dist/utilities/isArrayOfRows.js.map +0 -1
  359. package/dist/utilities/migrationTableExists.d.ts +0 -3
  360. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  361. package/dist/utilities/migrationTableExists.js +0 -9
  362. package/dist/utilities/migrationTableExists.js.map +0 -1
  363. package/dist/utilities/parseError.d.ts +0 -5
  364. package/dist/utilities/parseError.d.ts.map +0 -1
  365. package/dist/utilities/parseError.js +0 -17
  366. package/dist/utilities/parseError.js.map +0 -1
  367. package/dist/utilities/pushDevSchema.d.ts +0 -9
  368. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  369. package/dist/utilities/pushDevSchema.js +0 -58
  370. package/dist/utilities/pushDevSchema.js.map +0 -1
package/dist/types.d.ts CHANGED
@@ -1,99 +1,87 @@
1
- import type { ColumnBaseConfig, ColumnDataType, DrizzleConfig, ExtractTablesWithRelations, Relation, Relations } from 'drizzle-orm';
2
- import type { NodePgDatabase, NodePgQueryResultHKT } from 'drizzle-orm/node-postgres';
3
- import type { PgColumn, PgEnum, PgSchema, PgTableWithColumns, PgTransaction } from 'drizzle-orm/pg-core';
4
- import type { PgTableFn } from 'drizzle-orm/pg-core/table';
5
- import type { Payload } from 'payload';
6
- import type { BaseDatabaseAdapter } from 'payload/database';
7
- import type { PayloadRequestWithData } from 'payload/types';
1
+ import type { BasePostgresAdapter, GenericEnum, MigrateDownArgs, MigrateUpArgs, PostgresDB, PostgresSchemaHook } from '@payloadcms/drizzle/postgres';
2
+ import type { DrizzleAdapter } from '@payloadcms/drizzle/types';
3
+ import type { DrizzleConfig } from 'drizzle-orm';
4
+ import type { PgSchema, PgTableFn, PgTransactionConfig } from 'drizzle-orm/pg-core';
8
5
  import type { Pool, PoolConfig } from 'pg';
9
- export type DrizzleDB = NodePgDatabase<Record<string, unknown>>;
10
6
  export type Args = {
7
+ /**
8
+ * Transform the schema after it's built.
9
+ * You can use it to customize the schema with features that aren't supported by Payload.
10
+ * Examples may include: composite indices, generated columns, vectors
11
+ */
12
+ afterSchemaInit?: PostgresSchemaHook[];
13
+ /**
14
+ * Transform the schema before it's built.
15
+ * You can use it to preserve an existing database schema and if there are any collissions Payload will override them.
16
+ * To generate Drizzle schema from the database, see [Drizzle Kit introspection](https://orm.drizzle.team/kit-docs/commands#introspect--pull)
17
+ */
18
+ beforeSchemaInit?: PostgresSchemaHook[];
19
+ /**
20
+ * Pass `true` to disale auto database creation if it doesn't exist.
21
+ * @default false
22
+ */
23
+ disableCreateDatabase?: boolean;
24
+ extensions?: string[];
11
25
  idType?: 'serial' | 'uuid';
12
26
  localesSuffix?: string;
13
27
  logger?: DrizzleConfig['logger'];
14
28
  migrationDir?: string;
15
29
  pool: PoolConfig;
30
+ prodMigrations?: {
31
+ down: (args: MigrateDownArgs) => Promise<void>;
32
+ name: string;
33
+ up: (args: MigrateUpArgs) => Promise<void>;
34
+ }[];
16
35
  push?: boolean;
17
36
  relationshipsSuffix?: string;
18
- schemaName?: string;
19
- versionsSuffix?: string;
20
- };
21
- export type GenericColumn = PgColumn<ColumnBaseConfig<ColumnDataType, string>, Record<string, unknown>>;
22
- export type GenericColumns = {
23
- [x: string]: GenericColumn;
24
- };
25
- export type GenericTable = PgTableWithColumns<{
26
- columns: GenericColumns;
27
- dialect: string;
28
- name: string;
29
- schema: undefined;
30
- }>;
31
- export type GenericEnum = PgEnum<[string, ...string[]]>;
32
- export type GenericRelation = Relations<string, Record<string, Relation<string>>>;
33
- export type DrizzleTransaction = PgTransaction<NodePgQueryResultHKT, Record<string, unknown>, ExtractTablesWithRelations<Record<string, unknown>>>;
34
- export type PostgresAdapter = BaseDatabaseAdapter & {
35
- drizzle: DrizzleDB;
36
- enums: Record<string, GenericEnum>;
37
37
  /**
38
- * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name
39
- * Used for returning properly formed errors from unique fields
38
+ * The schema name to use for the database
39
+ * @experimental This only works when there are not other tables or enums of the same name in the database under a different schema. Awaiting fix from Drizzle.
40
40
  */
41
- fieldConstraints: Record<string, Record<string, string>>;
42
- idType: Args['idType'];
43
- localesSuffix?: string;
44
- logger: DrizzleConfig['logger'];
45
- pgSchema?: {
46
- table: PgTableFn;
47
- } | PgSchema;
48
- pool: Pool;
49
- poolOptions: Args['pool'];
50
- push: boolean;
51
- relations: Record<string, GenericRelation>;
52
- relationshipsSuffix?: string;
53
- schema: Record<string, GenericEnum | GenericRelation | GenericTable>;
54
- schemaName?: Args['schemaName'];
55
- sessions: {
56
- [id: string]: {
57
- db: DrizzleTransaction;
58
- reject: () => Promise<void>;
59
- resolve: () => Promise<void>;
60
- };
61
- };
62
- tableNameMap: Map<string, string>;
63
- tables: Record<string, GenericTable | PgTableWithColumns<any>>;
41
+ schemaName?: string;
42
+ tablesFilter?: string[];
43
+ transactionOptions?: false | PgTransactionConfig;
64
44
  versionsSuffix?: string;
65
45
  };
66
- export type IDType = 'integer' | 'numeric' | 'uuid' | 'varchar';
67
- export type PostgresAdapterResult = (args: {
68
- payload: Payload;
69
- }) => PostgresAdapter;
70
- export type MigrateUpArgs = {
71
- payload: Payload;
72
- req?: Partial<PayloadRequestWithData>;
73
- };
74
- export type MigrateDownArgs = {
75
- payload: Payload;
76
- req?: Partial<PayloadRequestWithData>;
77
- };
46
+ export type PostgresAdapter = {
47
+ pool: Pool;
48
+ poolOptions: PoolConfig;
49
+ } & BasePostgresAdapter;
78
50
  declare module 'payload' {
79
- interface DatabaseAdapter extends Omit<Args, 'migrationDir' | 'pool'>, BaseDatabaseAdapter {
80
- drizzle: DrizzleDB;
51
+ interface DatabaseAdapter extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>, DrizzleAdapter {
52
+ afterSchemaInit: PostgresSchemaHook[];
53
+ beforeSchemaInit: PostgresSchemaHook[];
54
+ beginTransaction: (options?: PgTransactionConfig) => Promise<null | number | string>;
55
+ drizzle: PostgresDB;
81
56
  enums: Record<string, GenericEnum>;
57
+ extensions: Record<string, boolean>;
58
+ /**
59
+ * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name
60
+ * Used for returning properly formed errors from unique fields
61
+ */
82
62
  fieldConstraints: Record<string, Record<string, string>>;
83
- localeSuffix?: string;
63
+ idType: Args['idType'];
64
+ initializing: Promise<void>;
65
+ localesSuffix?: string;
66
+ logger: DrizzleConfig['logger'];
67
+ pgSchema?: {
68
+ table: PgTableFn;
69
+ } | PgSchema;
84
70
  pool: Pool;
71
+ poolOptions: Args['pool'];
72
+ prodMigrations?: {
73
+ down: (args: MigrateDownArgs) => Promise<void>;
74
+ name: string;
75
+ up: (args: MigrateUpArgs) => Promise<void>;
76
+ }[];
85
77
  push: boolean;
86
- relations: Record<string, GenericRelation>;
78
+ rejectInitializing: () => void;
87
79
  relationshipsSuffix?: string;
88
- schema: Record<string, GenericEnum | GenericRelation | GenericTable>;
89
- sessions: {
90
- [id: string]: {
91
- db: DrizzleTransaction;
92
- reject: () => Promise<void>;
93
- resolve: () => Promise<void>;
94
- };
95
- };
96
- tables: Record<string, GenericTable>;
80
+ resolveInitializing: () => void;
81
+ schema: Record<string, unknown>;
82
+ schemaName?: Args['schemaName'];
83
+ tableNameMap: Map<string, string>;
84
+ tablesFilter?: string[];
97
85
  versionsSuffix?: string;
98
86
  }
99
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,0BAA0B,EAC1B,QAAQ,EACR,SAAS,EACV,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrF,OAAO,KAAK,EACV,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACd,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAE1C,MAAM,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAE/D,MAAM,MAAM,IAAI,GAAG;IACjB,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,MAAM,CAAC,E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AAO,CAAC,IAAI,CAAC,CAAA;YAC9C,IAAI,EAAE,MAAM,CAAA;YACZ,EAAE,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;SAC3C,EAAE,CAAA;QACH,IAAI,EAAE,OAAO,CAAA;QACb,kBAAkB,EAAE,MAAM,IAAI,CAAA;QAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAA;QAC5B,mBAAmB,EAAE,MAAM,IAAI,CAAA;QAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC/B,UAAU,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;QAC/B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;QACvB,cAAc,CAAC,EAAE,MAAM,CAAA;KACxB;CACF"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n ColumnBaseConfig,\n ColumnDataType,\n DrizzleConfig,\n ExtractTablesWithRelations,\n Relation,\n Relations,\n} from 'drizzle-orm'\nimport type { NodePgDatabase, NodePgQueryResultHKT } from 'drizzle-orm/node-postgres'\nimport type {\n PgColumn,\n PgEnum,\n PgSchema,\n PgTableWithColumns,\n PgTransaction,\n} from 'drizzle-orm/pg-core'\nimport type { PgTableFn } from 'drizzle-orm/pg-core/table'\nimport type { Payload } from 'payload'\nimport type { BaseDatabaseAdapter } from 'payload/database'\nimport type { PayloadRequestWithData } from 'payload/types'\nimport type { Pool, PoolConfig } from 'pg'\n\nexport type DrizzleDB = NodePgDatabase<Record<string, unknown>>\n\nexport type Args = {\n idType?: 'serial' | 'uuid'\n localesSuffix?: string\n logger?: DrizzleConfig['logger']\n migrationDir?: string\n pool: PoolConfig\n push?: boolean\n relationshipsSuffix?: string\n schemaName?: string\n versionsSuffix?: string\n}\n\nexport type GenericColumn = PgColumn<\n ColumnBaseConfig<ColumnDataType, string>,\n Record<string, unknown>\n>\n\nexport type GenericColumns = {\n [x: string]: GenericColumn\n}\n\nexport type GenericTable = PgTableWithColumns<{\n columns: GenericColumns\n dialect: string\n name: string\n schema: undefined\n}>\n\nexport type GenericEnum = PgEnum<[string, ...string[]]>\n\nexport type GenericRelation = Relations<string, Record<string, Relation<string>>>\n\nexport type DrizzleTransaction = PgTransaction<\n NodePgQueryResultHKT,\n Record<string, unknown>,\n ExtractTablesWithRelations<Record<string, unknown>>\n>\n\nexport type PostgresAdapter = BaseDatabaseAdapter & {\n drizzle: DrizzleDB\n enums: Record<string, GenericEnum>\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n idType: Args['idType']\n localesSuffix?: string\n logger: DrizzleConfig['logger']\n pgSchema?: { table: PgTableFn } | PgSchema\n pool: Pool\n poolOptions: Args['pool']\n push: boolean\n relations: Record<string, GenericRelation>\n relationshipsSuffix?: string\n schema: Record<string, GenericEnum | GenericRelation | GenericTable>\n schemaName?: Args['schemaName']\n sessions: {\n [id: string]: {\n db: DrizzleTransaction\n reject: () => Promise<void>\n resolve: () => Promise<void>\n }\n }\n tableNameMap: Map<string, string>\n tables: Record<string, GenericTable | PgTableWithColumns<any>>\n versionsSuffix?: string\n}\n\nexport type IDType = 'integer' | 'numeric' | 'uuid' | 'varchar'\n\nexport type PostgresAdapterResult = (args: { payload: Payload }) => PostgresAdapter\n\nexport type MigrateUpArgs = { payload: Payload; req?: Partial<PayloadRequestWithData> }\nexport type MigrateDownArgs = { payload: Payload; req?: Partial<PayloadRequestWithData> }\n\ndeclare module 'payload' {\n export interface DatabaseAdapter\n extends Omit<Args, 'migrationDir' | 'pool'>,\n BaseDatabaseAdapter {\n drizzle: DrizzleDB\n enums: Record<string, GenericEnum>\n fieldConstraints: Record<string, Record<string, string>>\n localeSuffix?: string\n pool: Pool\n push: boolean\n relations: Record<string, GenericRelation>\n relationshipsSuffix?: string\n schema: Record<string, GenericEnum | GenericRelation | GenericTable>\n sessions: {\n [id: string]: {\n db: DrizzleTransaction\n reject: () => Promise<void>\n resolve: () => Promise<void>\n }\n }\n tables: Record<string, GenericTable>\n versionsSuffix?: string\n }\n}\n"],"names":[],"rangeMappings":"","mappings":"AAkGA,WAAyF"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n BasePostgresAdapter,\n GenericEnum,\n MigrateDownArgs,\n MigrateUpArgs,\n PostgresDB,\n PostgresSchemaHook,\n} from '@payloadcms/drizzle/postgres'\nimport type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { DrizzleConfig } from 'drizzle-orm'\nimport type { PgSchema, PgTableFn, PgTransactionConfig } from 'drizzle-orm/pg-core'\nimport type { Pool, PoolConfig } from 'pg'\n\nexport type Args = {\n /**\n * Transform the schema after it's built.\n * You can use it to customize the schema with features that aren't supported by Payload.\n * Examples may include: composite indices, generated columns, vectors\n */\n afterSchemaInit?: PostgresSchemaHook[]\n /**\n * Transform the schema before it's built.\n * You can use it to preserve an existing database schema and if there are any collissions Payload will override them.\n * To generate Drizzle schema from the database, see [Drizzle Kit introspection](https://orm.drizzle.team/kit-docs/commands#introspect--pull)\n */\n beforeSchemaInit?: PostgresSchemaHook[]\n /**\n * Pass `true` to disale auto database creation if it doesn't exist.\n * @default false\n */\n disableCreateDatabase?: boolean\n extensions?: string[]\n idType?: 'serial' | 'uuid'\n localesSuffix?: string\n logger?: DrizzleConfig['logger']\n migrationDir?: string\n pool: PoolConfig\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n push?: boolean\n relationshipsSuffix?: string\n /**\n * The schema name to use for the database\n * @experimental This only works when there are not other tables or enums of the same name in the database under a different schema. Awaiting fix from Drizzle.\n */\n schemaName?: string\n tablesFilter?: string[]\n transactionOptions?: false | PgTransactionConfig\n versionsSuffix?: string\n}\n\nexport type PostgresAdapter = {\n pool: Pool\n poolOptions: PoolConfig\n} & BasePostgresAdapter\n\ndeclare module 'payload' {\n export interface DatabaseAdapter\n extends Omit<Args, 'idType' | 'logger' | 'migrationDir' | 'pool'>,\n DrizzleAdapter {\n afterSchemaInit: PostgresSchemaHook[]\n\n beforeSchemaInit: PostgresSchemaHook[]\n beginTransaction: (options?: PgTransactionConfig) => Promise<null | number | string>\n drizzle: PostgresDB\n enums: Record<string, GenericEnum>\n extensions: Record<string, boolean>\n /**\n * An object keyed on each table, with a key value pair where the constraint name is the key, followed by the dot-notation field name\n * Used for returning properly formed errors from unique fields\n */\n fieldConstraints: Record<string, Record<string, string>>\n idType: Args['idType']\n initializing: Promise<void>\n localesSuffix?: string\n logger: DrizzleConfig['logger']\n pgSchema?: { table: PgTableFn } | PgSchema\n pool: Pool\n poolOptions: Args['pool']\n prodMigrations?: {\n down: (args: MigrateDownArgs) => Promise<void>\n name: string\n up: (args: MigrateUpArgs) => Promise<void>\n }[]\n push: boolean\n rejectInitializing: () => void\n relationshipsSuffix?: string\n resolveInitializing: () => void\n schema: Record<string, unknown>\n schemaName?: Args['schemaName']\n tableNameMap: Map<string, string>\n tablesFilter?: string[]\n versionsSuffix?: string\n }\n}\n"],"names":[],"mappings":"AAsDA,WAGuB"}
package/license.md ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-2024 Payload CMS, Inc. <info@payloadcms.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-postgres",
3
- "version": "3.0.0-canary.f6e77b8",
3
+ "version": "3.0.0-canary.fb04843",
4
4
  "description": "The officially supported Postgres database adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -10,17 +10,29 @@
10
10
  },
11
11
  "license": "MIT",
12
12
  "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
13
+ "maintainers": [
14
+ {
15
+ "name": "Payload",
16
+ "email": "info@payloadcms.com",
17
+ "url": "https://payloadcms.com"
18
+ }
19
+ ],
13
20
  "type": "module",
14
21
  "exports": {
15
22
  ".": {
16
23
  "import": "./dist/index.js",
17
- "require": "./dist/index.js",
18
- "types": "./dist/index.d.ts"
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
19
26
  },
20
27
  "./types": {
21
28
  "import": "./dist/types.js",
22
- "require": "./dist/types.js",
23
- "types": "./dist/types.d.ts"
29
+ "types": "./dist/types.d.ts",
30
+ "default": "./dist/types.js"
31
+ },
32
+ "./migration-utils": {
33
+ "import": "./dist/exports/migration-utils.js",
34
+ "types": "./dist/exports/migration-utils.d.ts",
35
+ "default": "./dist/exports/migration-utils.js"
24
36
  }
25
37
  },
26
38
  "main": "./dist/index.js",
@@ -30,28 +42,34 @@
30
42
  "mock.js"
31
43
  ],
32
44
  "dependencies": {
33
- "@libsql/client": "^0.5.2",
34
- "console-table-printer": "2.11.2",
35
- "drizzle-kit": "0.20.14-1f2c838",
36
- "drizzle-orm": "0.29.4",
45
+ "@types/pg": "8.10.2",
46
+ "console-table-printer": "2.12.1",
47
+ "drizzle-kit": "0.28.0",
48
+ "drizzle-orm": "0.36.1",
37
49
  "pg": "8.11.3",
38
50
  "prompts": "2.4.2",
39
51
  "to-snake-case": "1.0.0",
40
- "uuid": "9.0.0"
52
+ "uuid": "10.0.0",
53
+ "@payloadcms/drizzle": "3.0.0-canary.fb04843"
41
54
  },
42
55
  "devDependencies": {
43
- "@types/pg": "8.10.2",
56
+ "@hyrious/esbuild-plugin-commonjs": "^0.2.4",
44
57
  "@types/to-snake-case": "1.0.0",
45
- "@payloadcms/eslint-config": "1.1.1",
46
- "payload": "3.0.0-canary.f6e77b8"
58
+ "esbuild": "0.23.1",
59
+ "payload": "3.0.0-canary.fb04843",
60
+ "@payloadcms/eslint-config": "3.0.0-beta.112"
47
61
  },
48
62
  "peerDependencies": {
49
- "payload": "3.0.0-canary.f6e77b8"
63
+ "payload": "3.0.0-canary.fb04843"
50
64
  },
51
65
  "scripts": {
52
- "build": "pnpm build:swc && pnpm build:types",
53
- "build:swc": "swc ./src -d ./dist --config-file .swcrc",
66
+ "build": "rimraf .dist && rimraf tsconfig.tsbuildinfo && pnpm build:types && pnpm build:swc && pnpm build:esbuild && pnpm renamePredefinedMigrations",
67
+ "build:esbuild": "echo skipping esbuild",
68
+ "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
54
69
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
55
- "clean": "rimraf {dist,*.tsbuildinfo}"
70
+ "clean": "rimraf {dist,*.tsbuildinfo}",
71
+ "lint": "eslint .",
72
+ "lint:fix": "eslint . --fix",
73
+ "renamePredefinedMigrations": "node --no-deprecation --import @swc-node/register/esm-register ./scripts/renamePredefinedMigrations.ts"
56
74
  }
57
75
  }
package/dist/count.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Count } from 'payload/database';
2
- export declare const count: Count;
3
- //# sourceMappingURL=count.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../src/count.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAY7C,eAAO,MAAM,KAAK,EAAE,KAiDnB,CAAA"}
package/dist/count.js DELETED
@@ -1,50 +0,0 @@
1
- import { sql } from 'drizzle-orm';
2
- import toSnakeCase from 'to-snake-case';
3
- import { chainMethods } from './find/chainMethods.js';
4
- import buildQuery from './queries/buildQuery.js';
5
- export const count = async function count({ collection, locale, req, where: whereArg }) {
6
- const collectionConfig = this.payload.collections[collection].config;
7
- const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug));
8
- const db = this.sessions[req.transactionID]?.db || this.drizzle;
9
- const table = this.tables[tableName];
10
- const { joinAliases, joins, where } = await buildQuery({
11
- adapter: this,
12
- fields: collectionConfig.fields,
13
- locale,
14
- tableName,
15
- where: whereArg
16
- });
17
- const selectCountMethods = [];
18
- joinAliases.forEach(({ condition, table })=>{
19
- selectCountMethods.push({
20
- args: [
21
- table,
22
- condition
23
- ],
24
- method: 'leftJoin'
25
- });
26
- });
27
- Object.entries(joins).forEach(([joinTable, condition])=>{
28
- if (joinTable) {
29
- selectCountMethods.push({
30
- args: [
31
- this.tables[joinTable],
32
- condition
33
- ],
34
- method: 'leftJoin'
35
- });
36
- }
37
- });
38
- const countResult = await chainMethods({
39
- methods: selectCountMethods,
40
- query: db.select({
41
- count: sql`count
42
- (DISTINCT ${this.tables[tableName].id})`
43
- }).from(table).where(where)
44
- });
45
- return {
46
- totalDocs: Number(countResult[0].count)
47
- };
48
- };
49
-
50
- //# sourceMappingURL=count.js.map
package/dist/count.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/count.ts"],"sourcesContent":["import type { Count } from 'payload/database'\nimport type { SanitizedCollectionConfig } from 'payload/types'\n\nimport { sql } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { ChainedMethods } from './find/chainMethods.js'\nimport type { PostgresAdapter } from './types.js'\n\nimport { chainMethods } from './find/chainMethods.js'\nimport buildQuery from './queries/buildQuery.js'\n\nexport const count: Count = async function count(\n this: PostgresAdapter,\n { collection, locale, req, where: whereArg },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))\n\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const table = this.tables[tableName]\n\n const { joinAliases, joins, where } = await buildQuery({\n adapter: this,\n fields: collectionConfig.fields,\n locale,\n tableName,\n where: whereArg,\n })\n\n const selectCountMethods: ChainedMethods = []\n\n joinAliases.forEach(({ condition, table }) => {\n selectCountMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n Object.entries(joins).forEach(([joinTable, condition]) => {\n if (joinTable) {\n selectCountMethods.push({\n args: [this.tables[joinTable], condition],\n method: 'leftJoin',\n })\n }\n })\n\n const countResult = await chainMethods({\n methods: selectCountMethods,\n query: db\n .select({\n count: sql<number>`count\n (DISTINCT ${this.tables[tableName].id})`,\n })\n .from(table)\n .where(where),\n })\n\n return { totalDocs: Number(countResult[0].count) }\n}\n"],"names":["sql","toSnakeCase","chainMethods","buildQuery","count","collection","locale","req","where","whereArg","collectionConfig","payload","collections","config","tableName","tableNameMap","get","slug","db","sessions","transactionID","drizzle","table","tables","joinAliases","joins","adapter","fields","selectCountMethods","forEach","condition","push","args","method","Object","entries","joinTable","countResult","methods","query","select","id","from","totalDocs","Number"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AACjC,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,YAAY,QAAQ,yBAAwB;AACrD,OAAOC,gB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A,OAAO;QAAEmC,WAAWC,OAAOP,WAAW,CAAC,EAAE,CAACjC,KAAK;IAAE;AACnD,EAAC"}
package/dist/create.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Create } from 'payload/database';
2
- export declare const create: Create;
3
- //# sourceMappingURL=create.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAQ9C,eAAO,MAAM,MAAM,EAAE,MAoBpB,CAAA"}
package/dist/create.js DELETED
@@ -1,19 +0,0 @@
1
- import toSnakeCase from 'to-snake-case';
2
- import { upsertRow } from './upsertRow/index.js';
3
- export const create = async function create({ collection: collectionSlug, data, req }) {
4
- const db = this.sessions[req.transactionID]?.db || this.drizzle;
5
- const collection = this.payload.collections[collectionSlug].config;
6
- const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
7
- const result = await upsertRow({
8
- adapter: this,
9
- data,
10
- db,
11
- fields: collection.fields,
12
- operation: 'create',
13
- req,
14
- tableName
15
- });
16
- return result;
17
- };
18
-
19
- //# sourceMappingURL=create.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create } from 'payload/database'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport const create: Create = async function create(\n this: PostgresAdapter,\n { collection: collectionSlug, data, req },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n const result = await upsertRow({\n adapter: this,\n data,\n db,\n fields: collection.fields,\n operation: 'create',\n req,\n tableName,\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","create","collection","collectionSlug","data","req","db","sessions","transactionID","drizzle","payload","collections","config","tableName","tableNameMap","get","slug","result","adapter","fields","operation"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,MAAMC,SAAiB,eAAeA,OAE3C,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,GAAG,EAAE;IAEzC,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMP,aAAa,IAAI,CAACQ,OAAO,CAACC,WAAW,CAACR,eAAe,CAACS,MAAM;IAElE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAChB,YAAYG,WAAWc,IAAI;IAEnE,MAAMC,SAAS,MAAMjB,UAAU;QAC7BkB,SAAS,IAAI;QACbd;QACAE;QACAa,QAAQjB,WAAWiB,MAAM;QACzBC,WAAW;QACXf;QACAQ;IACF;IAEA,OAAOI;AACT,EAAC"}
@@ -1,5 +0,0 @@
1
- import type { CreateGlobalArgs } from 'payload/database';
2
- import type { TypeWithID } from 'payload/types';
3
- import type { PostgresAdapter } from './types.js';
4
- export declare function createGlobal<T extends TypeWithID>(this: PostgresAdapter, { slug, data, req }: CreateGlobalArgs): Promise<T>;
5
- //# sourceMappingURL=createGlobal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAA0B,UAAU,EAAE,MAAM,eAAe,CAAA;AAIvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,YAAY,CAAC,CAAC,SAAS,UAAU,EACrD,IAAI,EAAE,eAAe,EACrB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAkC,EAAE,EAAE,gBAAgB,GACnE,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
@@ -1,19 +0,0 @@
1
- import toSnakeCase from 'to-snake-case';
2
- import { upsertRow } from './upsertRow/index.js';
3
- export async function createGlobal({ slug, data, req = {} }) {
4
- const db = this.sessions[req.transactionID]?.db || this.drizzle;
5
- const globalConfig = this.payload.globals.config.find((config)=>config.slug === slug);
6
- const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug));
7
- const result = await upsertRow({
8
- adapter: this,
9
- data,
10
- db,
11
- fields: globalConfig.fields,
12
- operation: 'create',
13
- req,
14
- tableName
15
- });
16
- return result;
17
- }
18
-
19
- //# sourceMappingURL=createGlobal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobalArgs } from 'payload/database'\nimport type { PayloadRequestWithData, TypeWithID } from 'payload/types'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobal<T extends TypeWithID>(\n this: PostgresAdapter,\n { slug, data, req = {} as PayloadRequestWithData }: CreateGlobalArgs,\n): Promise<T> {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n\n const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug))\n\n const result = await upsertRow<T>({\n adapter: this,\n data,\n db,\n fields: globalConfig.fields,\n operation: 'create',\n req,\n tableName,\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","createGlobal","slug","data","req","db","sessions","transactionID","drizzle","globalConfig","payload","globals","config","find","tableName","tableNameMap","get","result","adapter","fields","operation"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,aAEpB,EAAEC,IAAI,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAA2B,EAAoB;IAEpE,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOV,IAAI,KAAKA;IAElF,MAAMY,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACjB,YAAYU,aAAaP,IAAI;IAErE,MAAMe,SAAS,MAAMjB,UAAa;QAChCkB,SAAS,IAAI;QACbf;QACAE;QACAc,QAAQV,aAAaU,MAAM;QAC3BC,WAAW;QACXhB;QACAU;IACF;IAEA,OAAOG;AACT"}
@@ -1,6 +0,0 @@
1
- import type { TypeWithVersion } from 'payload/database';
2
- import type { TypeWithID } from 'payload/types';
3
- import { type CreateGlobalVersionArgs } from 'payload/database';
4
- import type { PostgresAdapter } from './types.js';
5
- export declare function createGlobalVersion<T extends TypeWithID>(this: PostgresAdapter, { autosave, globalSlug, req, versionData, }: CreateGlobalVersionArgs): Promise<TypeWithVersion<T>>;
6
- //# sourceMappingURL=createGlobalVersion.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAA0B,UAAU,EAAE,MAAM,eAAe,CAAA;AAGvE,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,eAAe,EACrB,EACE,QAAQ,EACR,UAAU,EACV,GAAkC,EAClC,WAAW,GACZ,EAAE,uBAAuB,+BAgC3B"}
@@ -1,33 +0,0 @@
1
- import { sql } from 'drizzle-orm';
2
- import { buildVersionGlobalFields } from 'payload/versions';
3
- import toSnakeCase from 'to-snake-case';
4
- import { upsertRow } from './upsertRow/index.js';
5
- export async function createGlobalVersion({ autosave, globalSlug, req = {}, versionData }) {
6
- const db = this.sessions[req.transactionID]?.db || this.drizzle;
7
- const global = this.payload.globals.config.find(({ slug })=>slug === globalSlug);
8
- const tableName = this.tableNameMap.get(`_${toSnakeCase(global.slug)}${this.versionsSuffix}`);
9
- const result = await upsertRow({
10
- adapter: this,
11
- data: {
12
- autosave,
13
- latest: true,
14
- version: versionData
15
- },
16
- db,
17
- fields: buildVersionGlobalFields(global),
18
- operation: 'create',
19
- req,
20
- tableName
21
- });
22
- const table = this.tables[tableName];
23
- if (global.versions.drafts) {
24
- await db.execute(sql`
25
- UPDATE ${table}
26
- SET latest = false
27
- WHERE ${table.id} != ${result.id};
28
- `);
29
- }
30
- return result;
31
- }
32
-
33
- //# sourceMappingURL=createGlobalVersion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import type { TypeWithVersion } from 'payload/database'\nimport type { PayloadRequestWithData, TypeWithID } from 'payload/types'\n\nimport { sql } from 'drizzle-orm'\nimport { type CreateGlobalVersionArgs } from 'payload/database'\nimport { buildVersionGlobalFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobalVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n {\n autosave,\n globalSlug,\n req = {} as PayloadRequestWithData,\n versionData,\n }: CreateGlobalVersionArgs,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const global = this.payload.globals.config.find(({ slug }) => slug === globalSlug)\n\n const tableName = this.tableNameMap.get(`_${toSnakeCase(global.slug)}${this.versionsSuffix}`)\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n version: versionData,\n },\n db,\n fields: buildVersionGlobalFields(global),\n operation: 'create',\n req,\n tableName,\n })\n\n const table = this.tables[tableName]\n\n if (global.versions.drafts) {\n await db.execute(sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id};\n `)\n }\n\n return result\n}\n"],"names":["sql","buildVersionGlobalFields","toSnakeCase","upsertRow","createGlobalVersion","autosave","globalSlug","req","versionData","db","sessions","transactionID","drizzle","global","payload","globals","config","find","slug","tableName","tableNameMap","get","versionsSuffix","result","adapter","data","latest","version","fields","operation","table","tables","versions","drafts","execute","id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AAEjC,SAASC,wBAAwB,QAAQ,mBAAkB;AAC3D,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,oBAEpB,EACEC,QAAQ,EACRC,UAAU,EACVC,MAAM,CAAC,CAA2B,EAClCC,WAAW,EACa;IAE1B,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,SAAS,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASZ;IAEvE,MAAMa,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAC,CAAC,CAAC,EAAEnB,YAAYW,OAAOK,IAAI,EAAE,EAAE,IAAI,CAACI,cAAc,CAAC,CAAC;IAE5F,MAAMC,SAAS,MAAMpB,UAA8B;QACjDqB,SAAS,IAAI;QACbC,MAAM;YACJpB;YACAqB,QAAQ;YACRC,SAASnB;QACX;QACAC;QACAmB,QAAQ3B,yBAAyBY;QACjCgB,WAAW;QACXtB;QACAY;IACF;IAEA,MAAMW,QAAQ,IAAI,CAACC,MAAM,CAACZ,UAAU;IAEpC,IAAIN,OAAOmB,QAAQ,CAACC,MAAM,EAAE;QAC1B,MAAMxB,GAAGyB,OAAO,CAAClC,GAAG,CAAC;aACZ,EAAE8B,MAAM;;YAET,EAAEA,MAAMK,EAAE,CAAC,IAAI,EAAEZ,OAAOY,EAAE,CAAC;IACnC,CAAC;IACH;IAEA,OAAOZ;AACT"}
@@ -1,3 +0,0 @@
1
- import type { CreateMigration } from 'payload/database';
2
- export declare const createMigration: CreateMigration;
3
- //# sourceMappingURL=createMigration.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createMigration.d.ts","sourceRoot":"","sources":["../src/createMigration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAqDvD,eAAO,MAAM,eAAe,EAAE,eA4E7B,CAAA"}
@@ -1,81 +0,0 @@
1
- /* eslint-disable no-restricted-syntax, no-await-in-loop */ import fs from 'fs';
2
- import { createRequire } from 'module';
3
- import prompts from 'prompts';
4
- const require = createRequire(import.meta.url);
5
- const migrationTemplate = (upSQL, downSQL)=>`import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
6
-
7
- export async function up({ payload }: MigrateUpArgs): Promise<void> {
8
- ${upSQL ? `await payload.db.drizzle.execute(sql\`
9
-
10
- ${upSQL}\`);
11
- ` : '// Migration code'}
12
- };
13
-
14
- export async function down({ payload }: MigrateDownArgs): Promise<void> {
15
- ${downSQL ? `await payload.db.drizzle.execute(sql\`
16
-
17
- ${downSQL}\`);
18
- ` : '// Migration code'}
19
- };
20
- `;
21
- const getDefaultDrizzleSnapshot = ()=>({
22
- id: '00000000-0000-0000-0000-000000000000',
23
- _meta: {
24
- columns: {},
25
- schemas: {},
26
- tables: {}
27
- },
28
- dialect: 'pg',
29
- enums: {},
30
- prevId: '00000000-0000-0000-0000-00000000000',
31
- schemas: {},
32
- tables: {},
33
- version: '5'
34
- });
35
- export const createMigration = async function createMigration({ forceAcceptWarning, migrationName, payload }) {
36
- const dir = payload.db.migrationDir;
37
- if (!fs.existsSync(dir)) {
38
- fs.mkdirSync(dir);
39
- }
40
- const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload');
41
- const [yyymmdd, hhmmss] = new Date().toISOString().split('T');
42
- const formattedDate = yyymmdd.replace(/\D/g, '');
43
- const formattedTime = hhmmss.split('.')[0].replace(/\D/g, '');
44
- const timestamp = `${formattedDate}_${formattedTime}`;
45
- const fileName = migrationName ? `${timestamp}_${migrationName.replace(/\W/g, '_')}` : `${timestamp}`;
46
- const filePath = `${dir}/${fileName}`;
47
- let drizzleJsonBefore = getDefaultDrizzleSnapshot();
48
- // Get latest migration snapshot
49
- const latestSnapshot = fs.readdirSync(dir).filter((file)=>file.endsWith('.json')).sort().reverse()?.[0];
50
- if (latestSnapshot) {
51
- const latestSnapshotJSON = JSON.parse(fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'));
52
- drizzleJsonBefore = latestSnapshotJSON;
53
- }
54
- const drizzleJsonAfter = generateDrizzleJson(this.schema);
55
- const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter);
56
- const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore);
57
- if (!sqlStatementsUp.length && !sqlStatementsDown.length && !forceAcceptWarning) {
58
- const { confirm: shouldCreateBlankMigration } = await prompts({
59
- name: 'confirm',
60
- type: 'confirm',
61
- initial: false,
62
- message: 'No schema changes detected. Would you like to create a blank migration file?'
63
- }, {
64
- onCancel: ()=>{
65
- process.exit(0);
66
- }
67
- });
68
- if (!shouldCreateBlankMigration) {
69
- process.exit(0);
70
- }
71
- }
72
- // write schema
73
- fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2));
74
- // write migration
75
- fs.writeFileSync(`${filePath}.ts`, migrationTemplate(sqlStatementsUp.length ? sqlStatementsUp?.join('\n') : undefined, sqlStatementsDown.length ? sqlStatementsDown?.join('\n') : undefined));
76
- payload.logger.info({
77
- msg: `Migration created at ${filePath}.ts`
78
- });
79
- };
80
-
81
- //# sourceMappingURL=createMigration.js.map