@payloadcms/db-postgres 3.0.0-beta.9 → 3.0.0-beta.90
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/connect.d.ts +1 -1
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +22 -13
- package/dist/connect.js.map +1 -1
- package/dist/exports/migration-utils.d.ts +2 -0
- package/dist/exports/migration-utils.d.ts.map +1 -0
- package/dist/exports/migration-utils.js +3 -0
- package/dist/exports/migration-utils.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -75
- package/dist/index.js.map +1 -1
- package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
- package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +20 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +169 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +191 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/index.d.ts +23 -0
- package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/index.js +211 -0
- package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +20 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +23 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
- package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/types.js +6 -0
- package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
- package/dist/types.d.ts +42 -80
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +37 -32
- package/dist/create.d.ts +0 -3
- package/dist/create.d.ts.map +0 -1
- package/dist/create.js +0 -21
- package/dist/create.js.map +0 -1
- package/dist/createGlobal.d.ts +0 -5
- package/dist/createGlobal.d.ts.map +0 -1
- package/dist/createGlobal.js +0 -21
- package/dist/createGlobal.js.map +0 -1
- package/dist/createGlobalVersion.d.ts +0 -6
- package/dist/createGlobalVersion.d.ts.map +0 -1
- package/dist/createGlobalVersion.js +0 -37
- package/dist/createGlobalVersion.js.map +0 -1
- package/dist/createMigration.d.ts +0 -3
- package/dist/createMigration.d.ts.map +0 -1
- package/dist/createMigration.js +0 -81
- package/dist/createMigration.js.map +0 -1
- package/dist/createVersion.d.ts +0 -5
- package/dist/createVersion.d.ts.map +0 -1
- package/dist/createVersion.js +0 -48
- package/dist/createVersion.js.map +0 -1
- package/dist/deleteMany.d.ts +0 -3
- package/dist/deleteMany.d.ts.map +0 -1
- package/dist/deleteMany.js +0 -31
- package/dist/deleteMany.js.map +0 -1
- package/dist/deleteOne.d.ts +0 -3
- package/dist/deleteOne.d.ts.map +0 -1
- package/dist/deleteOne.js +0 -62
- package/dist/deleteOne.js.map +0 -1
- package/dist/deleteVersions.d.ts +0 -3
- package/dist/deleteVersions.d.ts.map +0 -1
- package/dist/deleteVersions.js +0 -35
- package/dist/deleteVersions.js.map +0 -1
- package/dist/destroy.d.ts +0 -3
- package/dist/destroy.d.ts.map +0 -1
- package/dist/destroy.js +0 -11
- package/dist/destroy.js.map +0 -1
- package/dist/find/buildFindManyArgs.d.ts +0 -13
- package/dist/find/buildFindManyArgs.d.ts.map +0 -1
- package/dist/find/buildFindManyArgs.js +0 -64
- package/dist/find/buildFindManyArgs.js.map +0 -1
- package/dist/find/chainMethods.d.ts +0 -16
- package/dist/find/chainMethods.d.ts.map +0 -1
- package/dist/find/chainMethods.js +0 -12
- package/dist/find/chainMethods.js.map +0 -1
- package/dist/find/findMany.d.ts +0 -22
- package/dist/find/findMany.d.ts.map +0 -1
- package/dist/find/findMany.js +0 -163
- package/dist/find/findMany.js.map +0 -1
- package/dist/find/traverseFields.d.ts +0 -16
- package/dist/find/traverseFields.d.ts.map +0 -1
- package/dist/find/traverseFields.js +0 -154
- package/dist/find/traverseFields.js.map +0 -1
- package/dist/find.d.ts +0 -3
- package/dist/find.d.ts.map +0 -1
- package/dist/find.js +0 -24
- package/dist/find.js.map +0 -1
- package/dist/findGlobal.d.ts +0 -3
- package/dist/findGlobal.d.ts.map +0 -1
- package/dist/findGlobal.js +0 -26
- package/dist/findGlobal.js.map +0 -1
- package/dist/findGlobalVersions.d.ts +0 -3
- package/dist/findGlobalVersions.d.ts.map +0 -1
- package/dist/findGlobalVersions.js +0 -28
- package/dist/findGlobalVersions.js.map +0 -1
- package/dist/findOne.d.ts +0 -5
- package/dist/findOne.d.ts.map +0 -1
- package/dist/findOne.js +0 -24
- package/dist/findOne.js.map +0 -1
- package/dist/findVersions.d.ts +0 -3
- package/dist/findVersions.d.ts.map +0 -1
- package/dist/findVersions.js +0 -28
- package/dist/findVersions.js.map +0 -1
- package/dist/init.d.ts +0 -3
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -94
- package/dist/init.js.map +0 -1
- package/dist/migrate.d.ts +0 -3
- package/dist/migrate.d.ts.map +0 -1
- package/dist/migrate.js +0 -99
- package/dist/migrate.js.map +0 -1
- package/dist/migrateDown.d.ts +0 -3
- package/dist/migrateDown.d.ts.map +0 -1
- package/dist/migrateDown.js +0 -63
- package/dist/migrateDown.js.map +0 -1
- package/dist/migrateFresh.d.ts +0 -8
- package/dist/migrateFresh.d.ts.map +0 -1
- package/dist/migrateFresh.js +0 -72
- package/dist/migrateFresh.js.map +0 -1
- package/dist/migrateRefresh.d.ts +0 -6
- package/dist/migrateRefresh.d.ts.map +0 -1
- package/dist/migrateRefresh.js +0 -102
- package/dist/migrateRefresh.js.map +0 -1
- package/dist/migrateReset.d.ts +0 -6
- package/dist/migrateReset.d.ts.map +0 -1
- package/dist/migrateReset.js +0 -82
- package/dist/migrateReset.js.map +0 -1
- package/dist/migrateStatus.d.ts +0 -3
- package/dist/migrateStatus.d.ts.map +0 -1
- package/dist/migrateStatus.js +0 -44
- package/dist/migrateStatus.js.map +0 -1
- package/dist/queries/buildAndOrConditions.d.ts +0 -17
- package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
- package/dist/queries/buildAndOrConditions.js +0 -29
- package/dist/queries/buildAndOrConditions.js.map +0 -1
- package/dist/queries/buildQuery.d.ts +0 -31
- package/dist/queries/buildQuery.d.ts.map +0 -1
- package/dist/queries/buildQuery.js +0 -76
- package/dist/queries/buildQuery.js.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +0 -14
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
- package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js +0 -5
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
- package/dist/queries/createJSONQuery/index.d.ts +0 -10
- package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/index.js +0 -54
- package/dist/queries/createJSONQuery/index.js.map +0 -1
- package/dist/queries/getTableColumnFromPath.d.ts +0 -51
- package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
- package/dist/queries/getTableColumnFromPath.js +0 -412
- package/dist/queries/getTableColumnFromPath.js.map +0 -1
- package/dist/queries/operatorMap.d.ts +0 -18
- package/dist/queries/operatorMap.d.ts.map +0 -1
- package/dist/queries/operatorMap.js +0 -24
- package/dist/queries/operatorMap.js.map +0 -1
- package/dist/queries/parseParams.d.ts +0 -17
- package/dist/queries/parseParams.d.ts.map +0 -1
- package/dist/queries/parseParams.js +0 -182
- package/dist/queries/parseParams.js.map +0 -1
- package/dist/queries/sanitizeQueryValue.d.ts +0 -15
- package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
- package/dist/queries/sanitizeQueryValue.js +0 -90
- package/dist/queries/sanitizeQueryValue.js.map +0 -1
- package/dist/queries/selectDistinct.d.ts +0 -23
- package/dist/queries/selectDistinct.d.ts.map +0 -1
- package/dist/queries/selectDistinct.js +0 -41
- package/dist/queries/selectDistinct.js.map +0 -1
- package/dist/queryDrafts.d.ts +0 -3
- package/dist/queryDrafts.d.ts.map +0 -1
- package/dist/queryDrafts.js +0 -45
- package/dist/queryDrafts.js.map +0 -1
- package/dist/schema/build.d.ts +0 -29
- package/dist/schema/build.d.ts.map +0 -1
- package/dist/schema/build.js +0 -285
- package/dist/schema/build.js.map +0 -1
- package/dist/schema/createIndex.d.ts +0 -12
- package/dist/schema/createIndex.d.ts.map +0 -1
- package/dist/schema/createIndex.js +0 -18
- package/dist/schema/createIndex.js.map +0 -1
- package/dist/schema/getTableName.d.ts +0 -32
- package/dist/schema/getTableName.d.ts.map +0 -1
- package/dist/schema/getTableName.js +0 -31
- package/dist/schema/getTableName.js.map +0 -1
- package/dist/schema/idToUUID.d.ts +0 -3
- package/dist/schema/idToUUID.d.ts.map +0 -1
- package/dist/schema/idToUUID.js +0 -11
- package/dist/schema/idToUUID.js.map +0 -1
- package/dist/schema/parentIDColumnMap.d.ts +0 -4
- package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
- package/dist/schema/parentIDColumnMap.js +0 -9
- package/dist/schema/parentIDColumnMap.js.map +0 -1
- package/dist/schema/setColumnID.d.ts +0 -11
- package/dist/schema/setColumnID.d.ts.map +0 -1
- package/dist/schema/setColumnID.js +0 -24
- package/dist/schema/setColumnID.js.map +0 -1
- package/dist/schema/traverseFields.d.ts +0 -38
- package/dist/schema/traverseFields.d.ts.map +0 -1
- package/dist/schema/traverseFields.js +0 -530
- package/dist/schema/traverseFields.js.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -11
- package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.js +0 -70
- package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
- package/dist/transactions/beginTransaction.d.ts +0 -3
- package/dist/transactions/beginTransaction.d.ts.map +0 -1
- package/dist/transactions/beginTransaction.js +0 -47
- package/dist/transactions/beginTransaction.js.map +0 -1
- package/dist/transactions/commitTransaction.d.ts +0 -3
- package/dist/transactions/commitTransaction.d.ts.map +0 -1
- package/dist/transactions/commitTransaction.js +0 -14
- package/dist/transactions/commitTransaction.js.map +0 -1
- package/dist/transactions/rollbackTransaction.d.ts +0 -3
- package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
- package/dist/transactions/rollbackTransaction.js +0 -13
- package/dist/transactions/rollbackTransaction.js.map +0 -1
- package/dist/transform/read/hasManyNumber.d.ts +0 -10
- package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
- package/dist/transform/read/hasManyNumber.js +0 -10
- package/dist/transform/read/hasManyNumber.js.map +0 -1
- package/dist/transform/read/hasManyText.d.ts +0 -10
- package/dist/transform/read/hasManyText.d.ts.map +0 -1
- package/dist/transform/read/hasManyText.js +0 -10
- package/dist/transform/read/hasManyText.js.map +0 -1
- package/dist/transform/read/index.d.ts +0 -12
- package/dist/transform/read/index.d.ts.map +0 -1
- package/dist/transform/read/index.js +0 -43
- package/dist/transform/read/index.js.map +0 -1
- package/dist/transform/read/relationship.d.ts +0 -10
- package/dist/transform/read/relationship.d.ts.map +0 -1
- package/dist/transform/read/relationship.js +0 -64
- package/dist/transform/read/relationship.js.map +0 -1
- package/dist/transform/read/traverseFields.d.ts +0 -52
- package/dist/transform/read/traverseFields.d.ts.map +0 -1
- package/dist/transform/read/traverseFields.js +0 -421
- package/dist/transform/read/traverseFields.js.map +0 -1
- package/dist/transform/write/array.d.ts +0 -26
- package/dist/transform/write/array.d.ts.map +0 -1
- package/dist/transform/write/array.js +0 -58
- package/dist/transform/write/array.js.map +0 -1
- package/dist/transform/write/blocks.d.ts +0 -25
- package/dist/transform/write/blocks.d.ts.map +0 -1
- package/dist/transform/write/blocks.js +0 -54
- package/dist/transform/write/blocks.js.map +0 -1
- package/dist/transform/write/index.d.ts +0 -13
- package/dist/transform/write/index.d.ts.map +0 -1
- package/dist/transform/write/index.js +0 -41
- package/dist/transform/write/index.js.map +0 -1
- package/dist/transform/write/numbers.d.ts +0 -8
- package/dist/transform/write/numbers.d.ts.map +0 -1
- package/dist/transform/write/numbers.js +0 -11
- package/dist/transform/write/numbers.js.map +0 -1
- package/dist/transform/write/relationships.d.ts +0 -10
- package/dist/transform/write/relationships.d.ts.map +0 -1
- package/dist/transform/write/relationships.js +0 -23
- package/dist/transform/write/relationships.js.map +0 -1
- package/dist/transform/write/selects.d.ts +0 -8
- package/dist/transform/write/selects.d.ts.map +0 -1
- package/dist/transform/write/selects.js +0 -20
- package/dist/transform/write/selects.js.map +0 -1
- package/dist/transform/write/texts.d.ts +0 -8
- package/dist/transform/write/texts.d.ts.map +0 -1
- package/dist/transform/write/texts.js +0 -11
- package/dist/transform/write/texts.js.map +0 -1
- package/dist/transform/write/traverseFields.d.ts +0 -50
- package/dist/transform/write/traverseFields.d.ts.map +0 -1
- package/dist/transform/write/traverseFields.js +0 -428
- package/dist/transform/write/traverseFields.js.map +0 -1
- package/dist/transform/write/types.d.ts +0 -43
- package/dist/transform/write/types.d.ts.map +0 -1
- package/dist/transform/write/types.js +0 -3
- package/dist/transform/write/types.js.map +0 -1
- package/dist/update.d.ts +0 -3
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js +0 -58
- package/dist/update.js.map +0 -1
- package/dist/updateGlobal.d.ts +0 -5
- package/dist/updateGlobal.d.ts.map +0 -1
- package/dist/updateGlobal.js +0 -28
- package/dist/updateGlobal.js.map +0 -1
- package/dist/updateGlobalVersion.d.ts +0 -5
- package/dist/updateGlobalVersion.d.ts.map +0 -1
- package/dist/updateGlobalVersion.js +0 -40
- package/dist/updateGlobalVersion.js.map +0 -1
- package/dist/updateVersion.d.ts +0 -5
- package/dist/updateVersion.d.ts.map +0 -1
- package/dist/updateVersion.js +0 -40
- package/dist/updateVersion.js.map +0 -1
- package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
- package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
- package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
- package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
- package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
- package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
- package/dist/upsertRow/index.d.ts +0 -4
- package/dist/upsertRow/index.d.ts.map +0 -1
- package/dist/upsertRow/index.js +0 -276
- package/dist/upsertRow/index.js.map +0 -1
- package/dist/upsertRow/insertArrays.d.ts +0 -13
- package/dist/upsertRow/insertArrays.d.ts.map +0 -1
- package/dist/upsertRow/insertArrays.js +0 -68
- package/dist/upsertRow/insertArrays.js.map +0 -1
- package/dist/upsertRow/types.d.ts +0 -27
- package/dist/upsertRow/types.d.ts.map +0 -1
- package/dist/upsertRow/types.js +0 -3
- package/dist/upsertRow/types.js.map +0 -1
- package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
- package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
- package/dist/utilities/appendPrefixToKeys.js +0 -6
- package/dist/utilities/appendPrefixToKeys.js.map +0 -1
- package/dist/utilities/createBlocksMap.d.ts +0 -5
- package/dist/utilities/createBlocksMap.d.ts.map +0 -1
- package/dist/utilities/createBlocksMap.js +0 -29
- package/dist/utilities/createBlocksMap.js.map +0 -1
- package/dist/utilities/createMigrationTable.d.ts +0 -3
- package/dist/utilities/createMigrationTable.d.ts.map +0 -1
- package/dist/utilities/createMigrationTable.js +0 -13
- package/dist/utilities/createMigrationTable.js.map +0 -1
- package/dist/utilities/createRelationshipMap.d.ts +0 -2
- package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
- package/dist/utilities/createRelationshipMap.js +0 -19
- package/dist/utilities/createRelationshipMap.js.map +0 -1
- package/dist/utilities/hasLocalesTable.d.ts +0 -3
- package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
- package/dist/utilities/hasLocalesTable.js +0 -11
- package/dist/utilities/hasLocalesTable.js.map +0 -1
- package/dist/utilities/isArrayOfRows.d.ts +0 -2
- package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
- package/dist/utilities/isArrayOfRows.js +0 -5
- package/dist/utilities/isArrayOfRows.js.map +0 -1
- package/dist/utilities/migrationTableExists.d.ts +0 -3
- package/dist/utilities/migrationTableExists.d.ts.map +0 -1
- package/dist/utilities/migrationTableExists.js +0 -9
- package/dist/utilities/migrationTableExists.js.map +0 -1
- package/dist/utilities/parseError.d.ts +0 -5
- package/dist/utilities/parseError.d.ts.map +0 -1
- package/dist/utilities/parseError.js +0 -17
- package/dist/utilities/parseError.js.map +0 -1
- package/dist/utilities/pushDevSchema.d.ts +0 -9
- package/dist/utilities/pushDevSchema.d.ts.map +0 -1
- package/dist/utilities/pushDevSchema.js +0 -58
- package/dist/utilities/pushDevSchema.js.map +0 -1
- package/src/index.ts +0 -156
package/README.md
CHANGED
package/dist/connect.d.ts
CHANGED
package/dist/connect.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,SAAS,CAAA;AA6C/C,eAAO,MAAM,OAAO,EAAE,OAmDrB,CAAA"}
|
package/dist/connect.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { pushDevSchema } from '@payloadcms/drizzle';
|
2
2
|
import { drizzle } from 'drizzle-orm/node-postgres';
|
3
3
|
import pg from 'pg';
|
4
|
-
import { pushDevSchema } from './utilities/pushDevSchema.js';
|
5
4
|
const connectWithReconnect = async function({ adapter, payload, reconnect = false }) {
|
6
5
|
let result;
|
7
6
|
if (!reconnect) {
|
@@ -42,16 +41,19 @@ export const connect = async function connect(options = {
|
|
42
41
|
}) {
|
43
42
|
const { hotReload } = options;
|
44
43
|
this.schema = {
|
44
|
+
pgSchema: this.pgSchema,
|
45
45
|
...this.tables,
|
46
46
|
...this.relations,
|
47
47
|
...this.enums
|
48
48
|
};
|
49
49
|
try {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
if (!this.pool) {
|
51
|
+
this.pool = new pg.Pool(this.poolOptions);
|
52
|
+
await connectWithReconnect({
|
53
|
+
adapter: this,
|
54
|
+
payload: this.payload
|
55
|
+
});
|
56
|
+
}
|
55
57
|
const logger = this.logger || false;
|
56
58
|
this.drizzle = drizzle(this.pool, {
|
57
59
|
logger,
|
@@ -60,20 +62,27 @@ export const connect = async function connect(options = {
|
|
60
62
|
if (!hotReload) {
|
61
63
|
if (process.env.PAYLOAD_DROP_DATABASE === 'true') {
|
62
64
|
this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`);
|
63
|
-
await this.
|
64
|
-
|
65
|
-
|
66
|
-
`));
|
65
|
+
await this.dropDatabase({
|
66
|
+
adapter: this
|
67
|
+
});
|
67
68
|
this.payload.logger.info('---- DROPPED TABLES ----');
|
68
69
|
}
|
69
70
|
}
|
70
71
|
} catch (err) {
|
71
72
|
this.payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err);
|
73
|
+
if (typeof this.rejectInitializing === 'function') this.rejectInitializing();
|
72
74
|
process.exit(1);
|
73
75
|
}
|
74
76
|
// Only push schema if not in production
|
75
|
-
if (process.env.NODE_ENV
|
76
|
-
|
77
|
+
if (process.env.NODE_ENV !== 'production' && process.env.PAYLOAD_MIGRATING !== 'true' && this.push !== false) {
|
78
|
+
await pushDevSchema(this);
|
79
|
+
}
|
80
|
+
if (typeof this.resolveInitializing === 'function') this.resolveInitializing();
|
81
|
+
if (process.env.NODE_ENV === 'production' && this.prodMigrations) {
|
82
|
+
await this.migrate({
|
83
|
+
migrations: this.prodMigrations
|
84
|
+
});
|
85
|
+
}
|
77
86
|
};
|
78
87
|
|
79
88
|
//# sourceMappingURL=connect.js.map
|
package/dist/connect.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type {
|
1
|
+
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { DrizzleAdapter } from '@payloadcms/drizzle/types'\nimport type { Connect, Payload } from 'payload'\n\nimport { pushDevSchema } from '@payloadcms/drizzle'\nimport { drizzle } from 'drizzle-orm/node-postgres'\nimport pg from 'pg'\n\nimport type { PostgresAdapter } from './types.js'\n\nconst connectWithReconnect = async function ({\n adapter,\n payload,\n reconnect = false,\n}: {\n adapter: PostgresAdapter\n payload: Payload\n reconnect?: boolean\n}) {\n let result\n\n if (!reconnect) {\n result = await adapter.pool.connect()\n } else {\n try {\n result = await adapter.pool.connect()\n } catch (err) {\n setTimeout(() => {\n payload.logger.info('Reconnecting to postgres')\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }, 1000)\n }\n }\n if (!result) {\n return\n }\n result.prependListener('error', (err) => {\n try {\n if (err.code === 'ECONNRESET') {\n void connectWithReconnect({ adapter, payload, reconnect: true })\n }\n } catch (err) {\n // swallow error\n }\n })\n}\n\nexport const connect: Connect = async function connect(\n this: PostgresAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n this.schema = {\n pgSchema: this.pgSchema,\n ...this.tables,\n ...this.relations,\n ...this.enums,\n }\n\n try {\n if (!this.pool) {\n this.pool = new pg.Pool(this.poolOptions)\n await connectWithReconnect({ adapter: this, payload: this.payload })\n }\n\n const logger = this.logger || false\n this.drizzle = drizzle(this.pool, { logger, schema: this.schema })\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info(`---- DROPPING TABLES SCHEMA(${this.schemaName || 'public'}) ----`)\n await this.dropDatabase({ adapter: this })\n this.payload.logger.info('---- DROPPED TABLES ----')\n }\n }\n } catch (err) {\n this.payload.logger.error(`Error: cannot connect to Postgres. Details: ${err.message}`, err)\n if (typeof this.rejectInitializing === 'function') this.rejectInitializing()\n process.exit(1)\n }\n\n // Only push schema if not in production\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_MIGRATING !== 'true' &&\n this.push !== false\n ) {\n await pushDevSchema(this as unknown as DrizzleAdapter)\n }\n\n if (typeof this.resolveInitializing === 'function') this.resolveInitializing()\n\n if (process.env.NODE_ENV === 'production' && this.prodMigrations) {\n await this.migrate({ migrations: this.prodMigrations })\n }\n}\n"],"names":["pushDevSchema","drizzle","pg","connectWithReconnect","adapter","payload","reconnect","result","pool","connect","err","setTimeout","logger","info","prependListener","code","options","hotReload","schema","pgSchema","tables","relations","enums","Pool","poolOptions","process","env","PAYLOAD_DROP_DATABASE","schemaName","dropDatabase","error","message","rejectInitializing","exit","NODE_ENV","PAYLOAD_MIGRATING","push","resolveInitializing","prodMigrations","migrate","migrations"],"mappings":"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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"migration-utils.d.ts","sourceRoot":"","sources":["../../src/exports/migration-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/exports/migration-utils.ts"],"sourcesContent":["export { migratePostgresV2toV3 } from '../predefinedMigrations/v2-v3/index.js'\n"],"names":["migratePostgresV2toV3"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,yCAAwC"}
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { DatabaseAdapterObj } from 'payload
|
1
|
+
import type { DatabaseAdapterObj } from 'payload';
|
2
2
|
import type { Args, PostgresAdapter } from './types.js';
|
3
|
-
export type { MigrateDownArgs, MigrateUpArgs } from './types.js';
|
4
|
-
export { sql } from 'drizzle-orm';
|
5
3
|
export declare function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter>;
|
4
|
+
export type { MigrateDownArgs, MigrateUpArgs } from '@payloadcms/drizzle/postgres';
|
5
|
+
export { sql } from 'drizzle-orm';
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAW,MAAM,SAAS,CAAA;AAmD1D,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIvD,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAAC,eAAe,CAAC,CAwG/E;AAED,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAClF,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
@@ -1,84 +1,85 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import {
|
1
|
+
import { beginTransaction, commitTransaction, count, create, createGlobal, createGlobalVersion, createVersion, deleteMany, deleteOne, deleteVersions, destroy, find, findGlobal, findGlobalVersions, findMigrationDir, findOne, findVersions, migrate, migrateDown, migrateFresh, migrateRefresh, migrateReset, migrateStatus, operatorMap, queryDrafts, rollbackTransaction, updateGlobal, updateGlobalVersion, updateOne, updateVersion } from '@payloadcms/drizzle';
|
2
|
+
import { convertPathToJSONTraversal, countDistinct, createJSONQuery, createMigration, defaultDrizzleSnapshot, deleteWhere, dropDatabase, execute, getMigrationTemplate, init, insert, requireDrizzleKit } from '@payloadcms/drizzle/postgres';
|
3
|
+
import { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core';
|
4
|
+
import { createDatabaseAdapter } from 'payload';
|
4
5
|
import { connect } from './connect.js';
|
5
|
-
import { create } from './create.js';
|
6
|
-
import { createGlobal } from './createGlobal.js';
|
7
|
-
import { createGlobalVersion } from './createGlobalVersion.js';
|
8
|
-
import { createMigration } from './createMigration.js';
|
9
|
-
import { createVersion } from './createVersion.js';
|
10
|
-
import { deleteMany } from './deleteMany.js';
|
11
|
-
import { deleteOne } from './deleteOne.js';
|
12
|
-
import { deleteVersions } from './deleteVersions.js';
|
13
|
-
import { destroy } from './destroy.js';
|
14
|
-
import { find } from './find.js';
|
15
|
-
import { findGlobal } from './findGlobal.js';
|
16
|
-
import { findGlobalVersions } from './findGlobalVersions.js';
|
17
|
-
import { findOne } from './findOne.js';
|
18
|
-
import { findVersions } from './findVersions.js';
|
19
|
-
import { init } from './init.js';
|
20
|
-
import { migrate } from './migrate.js';
|
21
|
-
import { migrateDown } from './migrateDown.js';
|
22
|
-
import { migrateFresh } from './migrateFresh.js';
|
23
|
-
import { migrateRefresh } from './migrateRefresh.js';
|
24
|
-
import { migrateReset } from './migrateReset.js';
|
25
|
-
import { migrateStatus } from './migrateStatus.js';
|
26
|
-
import { queryDrafts } from './queryDrafts.js';
|
27
|
-
import { beginTransaction } from './transactions/beginTransaction.js';
|
28
|
-
import { commitTransaction } from './transactions/commitTransaction.js';
|
29
|
-
import { rollbackTransaction } from './transactions/rollbackTransaction.js';
|
30
|
-
import { updateOne } from './update.js';
|
31
|
-
import { updateGlobal } from './updateGlobal.js';
|
32
|
-
import { updateGlobalVersion } from './updateGlobalVersion.js';
|
33
|
-
import { updateVersion } from './updateVersion.js';
|
34
|
-
export { sql } from 'drizzle-orm';
|
35
6
|
export function postgresAdapter(args) {
|
7
|
+
const postgresIDType = args.idType || 'serial';
|
8
|
+
const payloadIDType = postgresIDType === 'serial' ? 'number' : 'text';
|
36
9
|
function adapter({ payload }) {
|
37
10
|
const migrationDir = findMigrationDir(args.migrationDir);
|
38
|
-
|
11
|
+
let resolveInitializing;
|
12
|
+
let rejectInitializing;
|
13
|
+
let adapterSchema;
|
14
|
+
const initializing = new Promise((res, rej)=>{
|
15
|
+
resolveInitializing = res;
|
16
|
+
rejectInitializing = rej;
|
17
|
+
});
|
18
|
+
if (args.schemaName) {
|
19
|
+
adapterSchema = pgSchema(args.schemaName);
|
20
|
+
} else {
|
21
|
+
adapterSchema = {
|
22
|
+
enum: pgEnum,
|
23
|
+
table: pgTable
|
24
|
+
};
|
25
|
+
}
|
39
26
|
return createDatabaseAdapter({
|
40
27
|
name: 'postgres',
|
41
|
-
|
42
|
-
blockTableNames: {},
|
28
|
+
defaultDrizzleSnapshot,
|
43
29
|
drizzle: undefined,
|
44
30
|
enums: {},
|
31
|
+
features: {
|
32
|
+
json: true
|
33
|
+
},
|
45
34
|
fieldConstraints: {},
|
46
|
-
|
35
|
+
getMigrationTemplate,
|
36
|
+
idType: postgresIDType,
|
37
|
+
initializing,
|
47
38
|
localesSuffix: args.localesSuffix || '_locales',
|
48
39
|
logger: args.logger,
|
49
|
-
|
40
|
+
operators: operatorMap,
|
41
|
+
pgSchema: adapterSchema,
|
50
42
|
pool: undefined,
|
51
43
|
poolOptions: args.pool,
|
44
|
+
prodMigrations: args.prodMigrations,
|
52
45
|
push: args.push,
|
53
46
|
relations: {},
|
54
47
|
relationshipsSuffix: args.relationshipsSuffix || '_rels',
|
55
48
|
schema: {},
|
56
49
|
schemaName: args.schemaName,
|
57
50
|
sessions: {},
|
51
|
+
tableNameMap: new Map(),
|
58
52
|
tables: {},
|
53
|
+
transactionOptions: args.transactionOptions || undefined,
|
59
54
|
versionsSuffix: args.versionsSuffix || '_v',
|
60
55
|
// DatabaseAdapter
|
61
|
-
beginTransaction,
|
56
|
+
beginTransaction: args.transactionOptions === false ? undefined : beginTransaction,
|
62
57
|
commitTransaction,
|
63
58
|
connect,
|
59
|
+
convertPathToJSONTraversal,
|
60
|
+
count,
|
61
|
+
countDistinct,
|
64
62
|
create,
|
65
63
|
createGlobal,
|
66
64
|
createGlobalVersion,
|
65
|
+
createJSONQuery,
|
67
66
|
createMigration,
|
68
67
|
createVersion,
|
69
|
-
|
70
|
-
* This represents how a default ID is treated in Payload as were a field type
|
71
|
-
*/ defaultIDType: idType === 'serial' ? 'number' : 'text',
|
68
|
+
defaultIDType: payloadIDType,
|
72
69
|
deleteMany,
|
73
70
|
deleteOne,
|
74
71
|
deleteVersions,
|
72
|
+
deleteWhere,
|
75
73
|
destroy,
|
74
|
+
dropDatabase,
|
75
|
+
execute,
|
76
76
|
find,
|
77
77
|
findGlobal,
|
78
78
|
findGlobalVersions,
|
79
79
|
findOne,
|
80
80
|
findVersions,
|
81
81
|
init,
|
82
|
+
insert,
|
82
83
|
migrate,
|
83
84
|
migrateDown,
|
84
85
|
migrateFresh,
|
@@ -86,8 +87,12 @@ export function postgresAdapter(args) {
|
|
86
87
|
migrateReset,
|
87
88
|
migrateStatus,
|
88
89
|
migrationDir,
|
90
|
+
packageName: '@payloadcms/db-postgres',
|
89
91
|
payload,
|
90
92
|
queryDrafts,
|
93
|
+
rejectInitializing,
|
94
|
+
requireDrizzleKit,
|
95
|
+
resolveInitializing,
|
91
96
|
rollbackTransaction,
|
92
97
|
updateGlobal,
|
93
98
|
updateGlobalVersion,
|
@@ -96,41 +101,10 @@ export function postgresAdapter(args) {
|
|
96
101
|
});
|
97
102
|
}
|
98
103
|
return {
|
99
|
-
defaultIDType:
|
104
|
+
defaultIDType: payloadIDType,
|
100
105
|
init: adapter
|
101
106
|
};
|
102
107
|
}
|
103
|
-
|
104
|
-
* Attempt to find migrations directory.
|
105
|
-
*
|
106
|
-
* Checks for the following directories in order:
|
107
|
-
* - `migrationDir` argument from Payload config
|
108
|
-
* - `src/migrations`
|
109
|
-
* - `dist/migrations`
|
110
|
-
* - `migrations`
|
111
|
-
*
|
112
|
-
* Defaults to `src/migrations`
|
113
|
-
*
|
114
|
-
* @param migrationDir
|
115
|
-
* @returns
|
116
|
-
*/ function findMigrationDir(migrationDir) {
|
117
|
-
const cwd = process.cwd();
|
118
|
-
const srcDir = path.resolve(cwd, 'src/migrations');
|
119
|
-
const distDir = path.resolve(cwd, 'dist/migrations');
|
120
|
-
const relativeMigrations = path.resolve(cwd, 'migrations');
|
121
|
-
// Use arg if provided
|
122
|
-
if (migrationDir) return migrationDir;
|
123
|
-
// Check other common locations
|
124
|
-
if (fs.existsSync(srcDir)) {
|
125
|
-
return srcDir;
|
126
|
-
}
|
127
|
-
if (fs.existsSync(distDir)) {
|
128
|
-
return distDir;
|
129
|
-
}
|
130
|
-
if (fs.existsSync(relativeMigrations)) {
|
131
|
-
return relativeMigrations;
|
132
|
-
}
|
133
|
-
return srcDir;
|
134
|
-
}
|
108
|
+
export { sql } from 'drizzle-orm';
|
135
109
|
|
136
110
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Payload } from 'payload'\nimport
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { DatabaseAdapterObj, Payload } from 'payload'\n\nimport {\n beginTransaction,\n commitTransaction,\n count,\n create,\n createGlobal,\n createGlobalVersion,\n createVersion,\n deleteMany,\n deleteOne,\n deleteVersions,\n destroy,\n find,\n findGlobal,\n findGlobalVersions,\n findMigrationDir,\n findOne,\n findVersions,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n operatorMap,\n queryDrafts,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n} from '@payloadcms/drizzle'\nimport {\n convertPathToJSONTraversal,\n countDistinct,\n createJSONQuery,\n createMigration,\n defaultDrizzleSnapshot,\n deleteWhere,\n dropDatabase,\n execute,\n getMigrationTemplate,\n init,\n insert,\n requireDrizzleKit,\n} from '@payloadcms/drizzle/postgres'\nimport { pgEnum, pgSchema, pgTable } from 'drizzle-orm/pg-core'\nimport { createDatabaseAdapter } from 'payload'\n\nimport type { Args, PostgresAdapter } from './types.js'\n\nimport { connect } from './connect.js'\n\nexport function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {\n const postgresIDType = args.idType || 'serial'\n const payloadIDType = postgresIDType === 'serial' ? 'number' : 'text'\n\n function adapter({ payload }: { payload: Payload }) {\n const migrationDir = findMigrationDir(args.migrationDir)\n let resolveInitializing\n let rejectInitializing\n let adapterSchema: PostgresAdapter['pgSchema']\n\n const initializing = new Promise<void>((res, rej) => {\n resolveInitializing = res\n rejectInitializing = rej\n })\n\n if (args.schemaName) {\n adapterSchema = pgSchema(args.schemaName)\n } else {\n adapterSchema = { enum: pgEnum, table: pgTable }\n }\n\n return createDatabaseAdapter<PostgresAdapter>({\n name: 'postgres',\n defaultDrizzleSnapshot,\n drizzle: undefined,\n enums: {},\n features: {\n json: true,\n },\n fieldConstraints: {},\n getMigrationTemplate,\n idType: postgresIDType,\n initializing,\n localesSuffix: args.localesSuffix || '_locales',\n logger: args.logger,\n operators: operatorMap,\n pgSchema: adapterSchema,\n pool: undefined,\n poolOptions: args.pool,\n prodMigrations: args.prodMigrations,\n push: args.push,\n relations: {},\n relationshipsSuffix: args.relationshipsSuffix || '_rels',\n schema: {},\n schemaName: args.schemaName,\n sessions: {},\n tableNameMap: new Map<string, string>(),\n tables: {},\n transactionOptions: args.transactionOptions || undefined,\n versionsSuffix: args.versionsSuffix || '_v',\n\n // DatabaseAdapter\n beginTransaction: args.transactionOptions === false ? undefined : beginTransaction,\n commitTransaction,\n connect,\n convertPathToJSONTraversal,\n count,\n countDistinct,\n create,\n createGlobal,\n createGlobalVersion,\n createJSONQuery,\n createMigration,\n createVersion,\n defaultIDType: payloadIDType,\n deleteMany,\n deleteOne,\n deleteVersions,\n deleteWhere,\n destroy,\n dropDatabase,\n execute,\n find,\n findGlobal,\n findGlobalVersions,\n findOne,\n findVersions,\n init,\n insert,\n migrate,\n migrateDown,\n migrateFresh,\n migrateRefresh,\n migrateReset,\n migrateStatus,\n migrationDir,\n packageName: '@payloadcms/db-postgres',\n payload,\n queryDrafts,\n rejectInitializing,\n requireDrizzleKit,\n resolveInitializing,\n rollbackTransaction,\n updateGlobal,\n updateGlobalVersion,\n updateOne,\n updateVersion,\n })\n }\n\n return {\n defaultIDType: payloadIDType,\n init: adapter,\n }\n}\n\nexport type { MigrateDownArgs, MigrateUpArgs } from '@payloadcms/drizzle/postgres'\nexport { sql } from 'drizzle-orm'\n"],"names":["beginTransaction","commitTransaction","count","create","createGlobal","createGlobalVersion","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findGlobal","findGlobalVersions","findMigrationDir","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","operatorMap","queryDrafts","rollbackTransaction","updateGlobal","updateGlobalVersion","updateOne","updateVersion","convertPathToJSONTraversal","countDistinct","createJSONQuery","createMigration","defaultDrizzleSnapshot","deleteWhere","dropDatabase","execute","getMigrationTemplate","init","insert","requireDrizzleKit","pgEnum","pgSchema","pgTable","createDatabaseAdapter","connect","postgresAdapter","args","postgresIDType","idType","payloadIDType","adapter","payload","migrationDir","resolveInitializing","rejectInitializing","adapterSchema","initializing","Promise","res","rej","schemaName","enum","table","name","drizzle","undefined","enums","features","json","fieldConstraints","localesSuffix","logger","operators","pool","poolOptions","prodMigrations","push","relations","relationshipsSuffix","schema","sessions","tableNameMap","Map","tables","transactionOptions","versionsSuffix","defaultIDType","packageName","sql"],"mappings":"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"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
declare const imports = "import { migratePostgresV2toV3 } from '@payloadcms/db-postgres/migration-utils'";
|
2
|
+
declare const upSQL = " await migratePostgresV2toV3({\n // enables logging of changes that will be made to the database\n debug: false,\n payload,\n req,\n })\n";
|
3
|
+
export { imports, upSQL };
|
4
|
+
//# sourceMappingURL=relationships-v2-v3.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"relationships-v2-v3.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/relationships-v2-v3.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,OAAO,oFAAoF,CAAA;AACjG,QAAA,MAAM,KAAK,mLAMV,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/predefinedMigrations/relationships-v2-v3.ts"],"sourcesContent":["const imports = `import { migratePostgresV2toV3 } from '@payloadcms/db-postgres/migration-utils'`\nconst upSQL = ` await migratePostgresV2toV3({\n // enables logging of changes that will be made to the database\n debug: false,\n payload,\n req,\n })\n`\n\nexport { imports, upSQL }\n"],"names":["imports","upSQL"],"mappings":"AAAA,MAAMA,UAAU,CAAC,+EAA+E,CAAC;AACjG,MAAMC,QAAQ,CAAC;;;;;;AAMf,CAAC;AAED,SAASD,OAAO,EAAEC,KAAK,GAAE"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
const imports = `import { migratePostgresV2toV3 } from '@payloadcms/db-postgres/migration-utils'`;
|
2
|
+
const upSQL = ` await migratePostgresV2toV3({
|
3
|
+
// enables logging of changes that will be made to the database
|
4
|
+
debug: false,
|
5
|
+
payload,
|
6
|
+
req,
|
7
|
+
})
|
8
|
+
`;
|
9
|
+
export { imports, upSQL };
|
10
|
+
|
11
|
+
//# sourceMappingURL=relationships-v2-v3.js.map
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import type { TransactionPg } from '@payloadcms/drizzle/types';
|
2
|
+
import type { Field, Payload, PayloadRequest } from 'payload';
|
3
|
+
import type { PostgresAdapter } from '../../../types.js';
|
4
|
+
import type { DocsToResave } from '../types.js';
|
5
|
+
type Args = {
|
6
|
+
adapter: PostgresAdapter;
|
7
|
+
collectionSlug?: string;
|
8
|
+
db: TransactionPg;
|
9
|
+
debug: boolean;
|
10
|
+
docsToResave: DocsToResave;
|
11
|
+
fields: Field[];
|
12
|
+
globalSlug?: string;
|
13
|
+
isVersions: boolean;
|
14
|
+
payload: Payload;
|
15
|
+
req: PayloadRequest;
|
16
|
+
tableName: string;
|
17
|
+
};
|
18
|
+
export declare const fetchAndResave: ({ adapter, collectionSlug, db, debug, docsToResave, fields, globalSlug, isVersions, payload, req, tableName, }: Args) => Promise<void>;
|
19
|
+
export {};
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/predefinedMigrations/v2-v3/fetchAndResave/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAI7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,EAAE,EAAE,aAAa,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,YAAY,EAAE,YAAY,CAAA;IAC1B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,cAAc,mHAYxB,IAAI,kBAwMN,CAAA"}
|
@@ -0,0 +1,169 @@
|
|
1
|
+
import { upsertRow } from '@payloadcms/drizzle';
|
2
|
+
import { traverseFields } from './traverseFields.js';
|
3
|
+
export const fetchAndResave = async ({ adapter, collectionSlug, db, debug, docsToResave, fields, globalSlug, isVersions, payload, req, tableName })=>{
|
4
|
+
for (const [id, rows] of Object.entries(docsToResave)){
|
5
|
+
if (collectionSlug) {
|
6
|
+
const collectionConfig = payload.collections[collectionSlug].config;
|
7
|
+
if (collectionConfig) {
|
8
|
+
if (isVersions) {
|
9
|
+
const doc = await payload.findVersionByID({
|
10
|
+
id,
|
11
|
+
collection: collectionSlug,
|
12
|
+
depth: 0,
|
13
|
+
fallbackLocale: null,
|
14
|
+
locale: 'all',
|
15
|
+
req,
|
16
|
+
showHiddenFields: true
|
17
|
+
});
|
18
|
+
if (debug) {
|
19
|
+
payload.logger.info(`The collection "${collectionConfig.slug}" version with ID ${id} will be migrated`);
|
20
|
+
}
|
21
|
+
traverseFields({
|
22
|
+
doc,
|
23
|
+
fields,
|
24
|
+
path: '',
|
25
|
+
rows
|
26
|
+
});
|
27
|
+
try {
|
28
|
+
await upsertRow({
|
29
|
+
id: doc.id,
|
30
|
+
adapter,
|
31
|
+
data: doc,
|
32
|
+
db,
|
33
|
+
fields,
|
34
|
+
ignoreResult: true,
|
35
|
+
operation: 'update',
|
36
|
+
req,
|
37
|
+
tableName
|
38
|
+
});
|
39
|
+
} catch (err) {
|
40
|
+
payload.logger.error(`"${collectionConfig.slug}" version with ID ${doc.id} FAILED TO MIGRATE`);
|
41
|
+
throw err;
|
42
|
+
}
|
43
|
+
if (debug) {
|
44
|
+
payload.logger.info(`"${collectionConfig.slug}" version with ID ${doc.id} migrated successfully!`);
|
45
|
+
}
|
46
|
+
} else {
|
47
|
+
const doc = await payload.findByID({
|
48
|
+
id,
|
49
|
+
collection: collectionSlug,
|
50
|
+
depth: 0,
|
51
|
+
fallbackLocale: null,
|
52
|
+
locale: 'all',
|
53
|
+
req,
|
54
|
+
showHiddenFields: true
|
55
|
+
});
|
56
|
+
if (debug) {
|
57
|
+
payload.logger.info(`The collection "${collectionConfig.slug}" with ID ${doc.id} will be migrated`);
|
58
|
+
}
|
59
|
+
traverseFields({
|
60
|
+
doc,
|
61
|
+
fields,
|
62
|
+
path: '',
|
63
|
+
rows
|
64
|
+
});
|
65
|
+
try {
|
66
|
+
await upsertRow({
|
67
|
+
id: doc.id,
|
68
|
+
adapter,
|
69
|
+
data: doc,
|
70
|
+
db,
|
71
|
+
fields,
|
72
|
+
ignoreResult: true,
|
73
|
+
operation: 'update',
|
74
|
+
req,
|
75
|
+
tableName
|
76
|
+
});
|
77
|
+
} catch (err) {
|
78
|
+
payload.logger.error(`The collection "${collectionConfig.slug}" with ID ${doc.id} has FAILED TO MIGRATE`);
|
79
|
+
throw err;
|
80
|
+
}
|
81
|
+
if (debug) {
|
82
|
+
payload.logger.info(`The collection "${collectionConfig.slug}" with ID ${doc.id} has migrated successfully!`);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
if (globalSlug) {
|
88
|
+
const globalConfig = payload.config.globals?.find((global)=>global.slug === globalSlug);
|
89
|
+
if (globalConfig) {
|
90
|
+
if (isVersions) {
|
91
|
+
const { docs } = await payload.findGlobalVersions({
|
92
|
+
slug: globalSlug,
|
93
|
+
depth: 0,
|
94
|
+
fallbackLocale: null,
|
95
|
+
limit: 0,
|
96
|
+
locale: 'all',
|
97
|
+
req,
|
98
|
+
showHiddenFields: true
|
99
|
+
});
|
100
|
+
if (debug) {
|
101
|
+
payload.logger.info(`${docs.length} global "${globalSlug}" versions will be migrated`);
|
102
|
+
}
|
103
|
+
for (const doc of docs){
|
104
|
+
traverseFields({
|
105
|
+
doc,
|
106
|
+
fields,
|
107
|
+
path: '',
|
108
|
+
rows
|
109
|
+
});
|
110
|
+
try {
|
111
|
+
await upsertRow({
|
112
|
+
id: doc.id,
|
113
|
+
adapter,
|
114
|
+
data: doc,
|
115
|
+
db,
|
116
|
+
fields,
|
117
|
+
ignoreResult: true,
|
118
|
+
operation: 'update',
|
119
|
+
req,
|
120
|
+
tableName
|
121
|
+
});
|
122
|
+
} catch (err) {
|
123
|
+
payload.logger.error(`"${globalSlug}" version with ID ${doc.id} FAILED TO MIGRATE`);
|
124
|
+
throw err;
|
125
|
+
}
|
126
|
+
if (debug) {
|
127
|
+
payload.logger.info(`"${globalSlug}" version with ID ${doc.id} migrated successfully!`);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
} else {
|
131
|
+
const doc = await payload.findGlobal({
|
132
|
+
slug: globalSlug,
|
133
|
+
depth: 0,
|
134
|
+
fallbackLocale: null,
|
135
|
+
locale: 'all',
|
136
|
+
req,
|
137
|
+
showHiddenFields: true
|
138
|
+
});
|
139
|
+
traverseFields({
|
140
|
+
doc,
|
141
|
+
fields,
|
142
|
+
path: '',
|
143
|
+
rows
|
144
|
+
});
|
145
|
+
try {
|
146
|
+
await upsertRow({
|
147
|
+
adapter,
|
148
|
+
data: doc,
|
149
|
+
db,
|
150
|
+
fields,
|
151
|
+
ignoreResult: true,
|
152
|
+
operation: 'update',
|
153
|
+
req,
|
154
|
+
tableName
|
155
|
+
});
|
156
|
+
} catch (err) {
|
157
|
+
payload.logger.error(`The global "${globalSlug}" has FAILED TO MIGRATE`);
|
158
|
+
throw err;
|
159
|
+
}
|
160
|
+
if (debug) {
|
161
|
+
payload.logger.info(`The global "${globalSlug}" has migrated successfully!`);
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
166
|
+
}
|
167
|
+
};
|
168
|
+
|
169
|
+
//# sourceMappingURL=index.js.map
|