@payloadcms/db-postgres 3.0.0-canary.6041f49 → 3.0.0-canary.6d066c2
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 +16 -13
- package/dist/connect.js.map +1 -1
- package/dist/countDistinct.d.ts +3 -0
- package/dist/countDistinct.d.ts.map +1 -0
- package/dist/countDistinct.js +24 -0
- package/dist/countDistinct.js.map +1 -0
- package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -0
- package/dist/createJSONQuery/convertPathToJSONTraversal.js.map +1 -0
- package/dist/createJSONQuery/formatJSONPathSegment.d.ts.map +1 -0
- package/dist/createJSONQuery/formatJSONPathSegment.js.map +1 -0
- package/dist/createJSONQuery/index.d.ts.map +1 -0
- package/dist/createJSONQuery/index.js.map +1 -0
- package/dist/createMigration.d.ts +1 -1
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +56 -57
- package/dist/createMigration.js.map +1 -1
- package/dist/defaultSnapshot.d.ts +3 -0
- package/dist/defaultSnapshot.d.ts.map +1 -0
- package/dist/defaultSnapshot.js +16 -0
- package/dist/defaultSnapshot.js.map +1 -0
- package/dist/deleteWhere.d.ts +3 -0
- package/dist/deleteWhere.d.ts.map +1 -0
- package/dist/deleteWhere.js +6 -0
- package/dist/deleteWhere.js.map +1 -0
- package/dist/dropDatabase.d.ts +3 -0
- package/dist/dropDatabase.d.ts.map +1 -0
- package/dist/dropDatabase.js +9 -0
- package/dist/dropDatabase.js.map +1 -0
- package/dist/execute.d.ts +3 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +11 -0
- package/dist/execute.js.map +1 -0
- 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/getMigrationTemplate.d.ts +3 -0
- package/dist/getMigrationTemplate.d.ts.map +1 -0
- package/dist/getMigrationTemplate.js +12 -0
- package/dist/getMigrationTemplate.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -64
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +17 -22
- package/dist/init.js.map +1 -1
- package/dist/insert.d.ts +3 -0
- package/dist/insert.d.ts.map +1 -0
- package/dist/insert.js +12 -0
- package/dist/insert.js.map +1 -0
- 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/requireDrizzleKit.d.ts +3 -0
- package/dist/requireDrizzleKit.d.ts.map +1 -0
- package/dist/requireDrizzleKit.js +5 -0
- package/dist/requireDrizzleKit.js.map +1 -0
- package/dist/schema/build.d.ts +9 -5
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +163 -114
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/createIndex.js.map +1 -1
- package/dist/schema/idToUUID.d.ts +1 -1
- package/dist/schema/idToUUID.d.ts.map +1 -1
- package/dist/schema/idToUUID.js.map +1 -1
- package/dist/schema/parentIDColumnMap.js.map +1 -1
- package/dist/schema/setColumnID.d.ts +1 -1
- package/dist/schema/setColumnID.d.ts.map +1 -1
- package/dist/schema/setColumnID.js +2 -2
- package/dist/schema/setColumnID.js.map +1 -1
- package/dist/schema/traverseFields.d.ts +5 -7
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +107 -46
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/types.d.ts +78 -32
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +22 -13
- package/dist/count.d.ts +0 -3
- package/dist/count.d.ts.map +0 -1
- package/dist/count.js +0 -50
- package/dist/count.js.map +0 -1
- package/dist/create.d.ts +0 -3
- package/dist/create.d.ts.map +0 -1
- package/dist/create.js +0 -19
- 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 -19
- 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 -33
- package/dist/createGlobalVersion.js.map +0 -1
- package/dist/createVersion.d.ts +0 -5
- package/dist/createVersion.d.ts.map +0 -1
- package/dist/createVersion.js +0 -44
- 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 -28
- 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 -59
- 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 -31
- 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 -138
- 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 -21
- 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 -23
- 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 -24
- 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 -21
- 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 -24
- package/dist/findVersions.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.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
- package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
- 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 -445
- 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 -41
- package/dist/queryDrafts.js.map +0 -1
- package/dist/schema/createTableName.d.ts +0 -30
- package/dist/schema/createTableName.d.ts.map +0 -1
- package/dist/schema/createTableName.js +0 -31
- package/dist/schema/createTableName.js.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
- package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
- 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 -55
- 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 -25
- 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 -36
- 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 -36
- 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 -277
- 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/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.d.ts +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.js +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.d.ts +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.js +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/index.d.ts +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/index.js +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/migrateRelationships.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\nimport type { Field, Payload, PayloadRequest } from 'payload'\n\nimport { sql } from 'drizzle-orm'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { DocsToResave, PathsToQuery } from './types.js'\n\nimport { fetchAndResave } from './fetchAndResave/index.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n db: TransactionPg\n debug: boolean\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n pathsToQuery: PathsToQuery\n payload: Payload\n req?: Partial<PayloadRequest>\n tableName: string\n}\n\nexport const migrateRelationships = async ({\n adapter,\n collectionSlug,\n db,\n debug,\n fields,\n globalSlug,\n isVersions,\n pathsToQuery,\n payload,\n req,\n tableName,\n}: Args) => {\n if (pathsToQuery.size === 0) return\n\n let offset = 0\n\n let paginationResult\n\n const where = Array.from(pathsToQuery).reduce((statement, path, i) => {\n return (statement += `\n\"${tableName}${adapter.relationshipsSuffix}\".\"path\" LIKE '${path}'${pathsToQuery.size !== i + 1 ? ' OR' : ''}\n`)\n }, '')\n\n while (typeof paginationResult === 'undefined' || paginationResult.rows.length > 0) {\n const paginationStatement = `SELECT DISTINCT parent_id FROM ${tableName}${adapter.relationshipsSuffix} WHERE\n ${where} ORDER BY parent_id LIMIT 500 OFFSET ${offset * 500};\n `\n\n paginationResult = await adapter.drizzle.execute(sql.raw(`${paginationStatement}`))\n\n if (paginationResult.rows.length === 0) return\n\n offset += 1\n\n const statement = `SELECT * FROM ${tableName}${adapter.relationshipsSuffix} WHERE\n (${where}) AND parent_id IN (${paginationResult.rows.map((row) => row.parent_id).join(', ')});\n`\n if (debug) {\n payload.logger.info('FINDING ROWS TO MIGRATE')\n payload.logger.info(statement)\n }\n\n const result = await adapter.drizzle.execute(sql.raw(`${statement}`))\n\n const docsToResave: DocsToResave = {}\n\n result.rows.forEach((row) => {\n const parentID = row.parent_id\n\n if (typeof parentID === 'string' || typeof parentID === 'number') {\n if (!docsToResave[parentID]) docsToResave[parentID] = []\n docsToResave[parentID].push(row)\n }\n })\n\n await fetchAndResave({\n adapter,\n collectionSlug,\n db,\n debug,\n docsToResave,\n fields,\n globalSlug,\n isVersions,\n payload,\n req: req as unknown as PayloadRequest,\n tableName,\n })\n }\n\n const deleteStatement = `DELETE FROM ${tableName}${adapter.relationshipsSuffix} WHERE ${where}`\n if (debug) {\n payload.logger.info('DELETING ROWS')\n payload.logger.info(deleteStatement)\n }\n await db.execute(sql.raw(`${deleteStatement}`))\n}\n"],"names":["sql","fetchAndResave","migrateRelationships","adapter","collectionSlug","db","debug","fields","globalSlug","isVersions","pathsToQuery","payload","req","tableName","size","offset","paginationResult","where","Array","from","reduce","statement","path","i","relationshipsSuffix","rows","length","paginationStatement","drizzle","execute","raw","map","row","parent_id","join","logger","info","result","docsToResave","forEach","parentID","push","deleteStatement"],"mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AAKjC,SAASC,cAAc,QAAQ,4BAA2B;AAgB1D,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,OAAO,EACPC,cAAc,EACdC,EAAE,EACFC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,OAAO,EACPC,GAAG,EACHC,SAAS,EACJ;IACL,IAAIH,aAAaI,IAAI,KAAK,GAAG;IAE7B,IAAIC,SAAS;IAEb,IAAIC;IAEJ,MAAMC,QAAQC,MAAMC,IAAI,CAACT,cAAcU,MAAM,CAAC,CAACC,WAAWC,MAAMC;QAC9D,OAAQF,aAAa,CAAC;CACzB,EAAER,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC,eAAe,EAAEF,KAAK,CAAC,EAAEZ,aAAaI,IAAI,KAAKS,IAAI,IAAI,QAAQ,GAAG;AAC7G,CAAC;IACC,GAAG;IAEH,MAAO,OAAOP,qBAAqB,eAAeA,iBAAiBS,IAAI,CAACC,MAAM,GAAG,EAAG;QAClF,MAAMC,sBAAsB,CAAC,+BAA+B,EAAEd,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC;IACtG,EAAEP,MAAM,qCAAqC,EAAEF,SAAS,IAAI;EAC9D,CAAC;QAECC,mBAAmB,MAAMb,QAAQyB,OAAO,CAACC,OAAO,CAAC7B,IAAI8B,GAAG,CAAC,CAAC,EAAEH,oBAAoB,CAAC;QAEjF,IAAIX,iBAAiBS,IAAI,CAACC,MAAM,KAAK,GAAG;QAExCX,UAAU;QAEV,MAAMM,YAAY,CAAC,cAAc,EAAER,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC;KAC1E,EAAEP,MAAM,oBAAoB,EAAED,iBAAiBS,IAAI,CAACM,GAAG,CAAC,CAACC,MAAQA,IAAIC,SAAS,EAAEC,IAAI,CAAC,MAAM;AAChG,CAAC;QACG,IAAI5B,OAAO;YACTK,QAAQwB,MAAM,CAACC,IAAI,CAAC;YACpBzB,QAAQwB,MAAM,CAACC,IAAI,CAACf;QACtB;QAEA,MAAMgB,SAAS,MAAMlC,QAAQyB,OAAO,CAACC,OAAO,CAAC7B,IAAI8B,GAAG,CAAC,CAAC,EAAET,UAAU,CAAC;QAEnE,MAAMiB,eAA6B,CAAC;QAEpCD,OAAOZ,IAAI,CAACc,OAAO,CAAC,CAACP;YACnB,MAAMQ,WAAWR,IAAIC,SAAS;YAE9B,IAAI,OAAOO,aAAa,YAAY,OAAOA,aAAa,UAAU;gBAChE,IAAI,CAACF,YAAY,CAACE,SAAS,EAAEF,YAAY,CAACE,SAAS,GAAG,EAAE;gBACxDF,YAAY,CAACE,SAAS,CAACC,IAAI,CAACT;YAC9B;QACF;QAEA,MAAM/B,eAAe;YACnBE;YACAC;YACAC;YACAC;YACAgC;YACA/B;YACAC;YACAC;YACAE;YACAC,KAAKA;YACLC;QACF;IACF;IAEA,MAAM6B,kBAAkB,CAAC,YAAY,EAAE7B,UAAU,EAAEV,QAAQqB,mBAAmB,CAAC,OAAO,EAAEP,MAAM,CAAC;IAC/F,IAAIX,OAAO;QACTK,QAAQwB,MAAM,CAACC,IAAI,CAAC;QACpBzB,QAAQwB,MAAM,CAACC,IAAI,CAACM;IACtB;IACA,MAAMrC,GAAGwB,OAAO,CAAC7B,IAAI8B,GAAG,CAAC,CAAC,EAAEY,gBAAgB,CAAC;AAC/C,EAAC"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import type { TransactionPg } from '@payloadcms/drizzle/types';
|
2
|
+
import type { Field, Payload } from 'payload';
|
3
|
+
import type { PostgresAdapter } from '../../types.js';
|
4
|
+
import type { PathsToQuery } from './types.js';
|
5
|
+
type Args = {
|
6
|
+
adapter: PostgresAdapter;
|
7
|
+
collectionSlug?: string;
|
8
|
+
columnPrefix: string;
|
9
|
+
db: TransactionPg;
|
10
|
+
disableNotNull: boolean;
|
11
|
+
fields: Field[];
|
12
|
+
globalSlug?: string;
|
13
|
+
isVersions: boolean;
|
14
|
+
newTableName: string;
|
15
|
+
parentTableName: string;
|
16
|
+
path: string;
|
17
|
+
pathsToQuery: PathsToQuery;
|
18
|
+
payload: Payload;
|
19
|
+
rootTableName: string;
|
20
|
+
};
|
21
|
+
export declare const traverseFields: (args: Args) => void;
|
22
|
+
export {};
|
23
|
+
//# sourceMappingURL=traverseFields.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAK7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,EAAE,EAAE,aAAa,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,SAAU,IAAI,SA0FxC,CAAA"}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import { tabHasName } from 'payload/shared';
|
2
|
+
import toSnakeCase from 'to-snake-case';
|
3
|
+
export const traverseFields = (args)=>{
|
4
|
+
args.fields.forEach((field)=>{
|
5
|
+
switch(field.type){
|
6
|
+
case 'group':
|
7
|
+
{
|
8
|
+
let newTableName = `${args.newTableName}_${toSnakeCase(field.name)}`;
|
9
|
+
if (field.localized && args.payload.config.localization) {
|
10
|
+
newTableName += args.adapter.localesSuffix;
|
11
|
+
}
|
12
|
+
return traverseFields({
|
13
|
+
...args,
|
14
|
+
columnPrefix: `${args.columnPrefix}${toSnakeCase(field.name)}_`,
|
15
|
+
fields: field.fields,
|
16
|
+
newTableName,
|
17
|
+
path: `${args.path ? `${args.path}.` : ''}${field.name}`
|
18
|
+
});
|
19
|
+
}
|
20
|
+
case 'row':
|
21
|
+
case 'collapsible':
|
22
|
+
{
|
23
|
+
return traverseFields({
|
24
|
+
...args,
|
25
|
+
fields: field.fields
|
26
|
+
});
|
27
|
+
}
|
28
|
+
case 'array':
|
29
|
+
{
|
30
|
+
const newTableName = args.adapter.tableNameMap.get(`${args.newTableName}_${toSnakeCase(field.name)}`);
|
31
|
+
return traverseFields({
|
32
|
+
...args,
|
33
|
+
columnPrefix: '',
|
34
|
+
fields: field.fields,
|
35
|
+
newTableName,
|
36
|
+
parentTableName: newTableName,
|
37
|
+
path: `${args.path ? `${args.path}.` : ''}${field.name}.%`
|
38
|
+
});
|
39
|
+
}
|
40
|
+
case 'blocks':
|
41
|
+
{
|
42
|
+
return field.blocks.forEach((block)=>{
|
43
|
+
const newTableName = args.adapter.tableNameMap.get(`${args.rootTableName}_blocks_${toSnakeCase(block.slug)}`);
|
44
|
+
traverseFields({
|
45
|
+
...args,
|
46
|
+
columnPrefix: '',
|
47
|
+
fields: block.fields,
|
48
|
+
newTableName,
|
49
|
+
parentTableName: newTableName,
|
50
|
+
path: `${args.path ? `${args.path}.` : ''}${field.name}.%`
|
51
|
+
});
|
52
|
+
});
|
53
|
+
}
|
54
|
+
case 'tabs':
|
55
|
+
{
|
56
|
+
return field.tabs.forEach((tab)=>{
|
57
|
+
if (tabHasName(tab)) {
|
58
|
+
args.columnPrefix = `${args.columnPrefix}_${toSnakeCase(tab.name)}_`;
|
59
|
+
args.path = `${args.path ? `${args.path}.` : ''}${tab.name}`;
|
60
|
+
args.newTableName = `${args.newTableName}_${toSnakeCase(tab.name)}`;
|
61
|
+
if (tab.localized && args.payload.config.localization) {
|
62
|
+
args.newTableName += args.adapter.localesSuffix;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
traverseFields({
|
66
|
+
...args,
|
67
|
+
fields: tab.fields
|
68
|
+
});
|
69
|
+
});
|
70
|
+
}
|
71
|
+
case 'relationship':
|
72
|
+
case 'upload':
|
73
|
+
{
|
74
|
+
if (typeof field.relationTo === 'string') {
|
75
|
+
if (field.type === 'upload' || !field.hasMany) {
|
76
|
+
args.pathsToQuery.add(`${args.path ? `${args.path}.` : ''}${field.name}`);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
return null;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
});
|
83
|
+
};
|
84
|
+
|
85
|
+
//# sourceMappingURL=traverseFields.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/traverseFields.ts"],"sourcesContent":["import type { TransactionPg } from '@payloadcms/drizzle/types'\nimport type { Field, Payload } from 'payload'\n\nimport { tabHasName } from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { PathsToQuery } from './types.js'\n\ntype Args = {\n adapter: PostgresAdapter\n collectionSlug?: string\n columnPrefix: string\n db: TransactionPg\n disableNotNull: boolean\n fields: Field[]\n globalSlug?: string\n isVersions: boolean\n newTableName: string\n parentTableName: string\n path: string\n pathsToQuery: PathsToQuery\n payload: Payload\n rootTableName: string\n}\n\nexport const traverseFields = (args: Args) => {\n args.fields.forEach((field) => {\n switch (field.type) {\n case 'group': {\n let newTableName = `${args.newTableName}_${toSnakeCase(field.name)}`\n\n if (field.localized && args.payload.config.localization) {\n newTableName += args.adapter.localesSuffix\n }\n\n return traverseFields({\n ...args,\n columnPrefix: `${args.columnPrefix}${toSnakeCase(field.name)}_`,\n fields: field.fields,\n newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}`,\n })\n }\n\n case 'row':\n case 'collapsible': {\n return traverseFields({\n ...args,\n fields: field.fields,\n })\n }\n\n case 'array': {\n const newTableName = args.adapter.tableNameMap.get(\n `${args.newTableName}_${toSnakeCase(field.name)}`,\n )\n\n return traverseFields({\n ...args,\n columnPrefix: '',\n fields: field.fields,\n newTableName,\n parentTableName: newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}.%`,\n })\n }\n\n case 'blocks': {\n return field.blocks.forEach((block) => {\n const newTableName = args.adapter.tableNameMap.get(\n `${args.rootTableName}_blocks_${toSnakeCase(block.slug)}`,\n )\n\n traverseFields({\n ...args,\n columnPrefix: '',\n fields: block.fields,\n newTableName,\n parentTableName: newTableName,\n path: `${args.path ? `${args.path}.` : ''}${field.name}.%`,\n })\n })\n }\n\n case 'tabs': {\n return field.tabs.forEach((tab) => {\n if (tabHasName(tab)) {\n args.columnPrefix = `${args.columnPrefix}_${toSnakeCase(tab.name)}_`\n args.path = `${args.path ? `${args.path}.` : ''}${tab.name}`\n args.newTableName = `${args.newTableName}_${toSnakeCase(tab.name)}`\n\n if (tab.localized && args.payload.config.localization) {\n args.newTableName += args.adapter.localesSuffix\n }\n }\n\n traverseFields({\n ...args,\n fields: tab.fields,\n })\n })\n }\n\n case 'relationship':\n case 'upload': {\n if (typeof field.relationTo === 'string') {\n if (field.type === 'upload' || !field.hasMany) {\n args.pathsToQuery.add(`${args.path ? `${args.path}.` : ''}${field.name}`)\n }\n }\n\n return null\n }\n }\n })\n}\n"],"names":["tabHasName","toSnakeCase","traverseFields","args","fields","forEach","field","type","newTableName","name","localized","payload","config","localization","adapter","localesSuffix","columnPrefix","path","tableNameMap","get","parentTableName","blocks","block","rootTableName","slug","tabs","tab","relationTo","hasMany","pathsToQuery","add"],"mappings":"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"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* Set of all paths which should be moved
|
3
|
+
* This will be built up into one WHERE query
|
4
|
+
*/
|
5
|
+
export type PathsToQuery = Set<string>;
|
6
|
+
export type DocsToResave = {
|
7
|
+
[id: number | string]: Record<string, unknown>[];
|
8
|
+
};
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/predefinedMigrations/v2-v3/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;AAEtC,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACjD,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../../src/predefinedMigrations/v2-v3/types.ts"],"sourcesContent":["/**\n * Set of all paths which should be moved\n * This will be built up into one WHERE query\n */\nexport type PathsToQuery = Set<string>\n\nexport type DocsToResave = {\n [id: number | string]: Record<string, unknown>[]\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAGD,WAEC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"requireDrizzleKit.d.ts","sourceRoot":"","sources":["../src/requireDrizzleKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAIlE,eAAO,MAAM,iBAAiB,EAAE,iBAAwD,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/requireDrizzleKit.ts"],"sourcesContent":["import type { RequireDrizzleKit } from '@payloadcms/drizzle/types'\n\nimport { createRequire } from 'module'\nconst require = createRequire(import.meta.url)\nexport const requireDrizzleKit: RequireDrizzleKit = () => require('drizzle-kit/payload')\n"],"names":["createRequire","require","url","requireDrizzleKit"],"mappings":"AAEA,SAASA,aAAa,QAAQ,SAAQ;AACtC,MAAMC,UAAUD,cAAc,YAAYE,GAAG;AAC7C,OAAO,MAAMC,oBAAuC,IAAMF,QAAQ,uBAAsB"}
|
package/dist/schema/build.d.ts
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
import type { ForeignKeyBuilder, IndexBuilder, PgColumnBuilder, UniqueConstraintBuilder } from 'drizzle-orm/pg-core';
|
2
|
-
import type { Field } from 'payload
|
2
|
+
import type { Field } from 'payload';
|
3
3
|
import type { GenericColumns, PostgresAdapter } from '../types.js';
|
4
4
|
export type BaseExtraConfig = Record<string, (cols: GenericColumns) => ForeignKeyBuilder | IndexBuilder | UniqueConstraintBuilder>;
|
5
|
+
export type RelationMap = Map<string, {
|
6
|
+
localized: boolean;
|
7
|
+
target: string;
|
8
|
+
type: 'many' | 'one';
|
9
|
+
}>;
|
5
10
|
type Args = {
|
6
11
|
adapter: PostgresAdapter;
|
7
12
|
baseColumns?: Record<string, PgColumnBuilder>;
|
8
13
|
baseExtraConfig?: BaseExtraConfig;
|
9
14
|
buildNumbers?: boolean;
|
10
15
|
buildRelationships?: boolean;
|
11
|
-
buildTexts?: boolean;
|
12
16
|
disableNotNull: boolean;
|
13
17
|
disableUnique: boolean;
|
14
18
|
fields: Field[];
|
15
|
-
rootRelationsToBuild?:
|
19
|
+
rootRelationsToBuild?: RelationMap;
|
16
20
|
rootRelationships?: Set<string>;
|
17
21
|
rootTableIDColType?: string;
|
18
22
|
rootTableName?: string;
|
@@ -23,8 +27,8 @@ type Args = {
|
|
23
27
|
type Result = {
|
24
28
|
hasManyNumberField: 'index' | boolean;
|
25
29
|
hasManyTextField: 'index' | boolean;
|
26
|
-
relationsToBuild:
|
30
|
+
relationsToBuild: RelationMap;
|
27
31
|
};
|
28
|
-
export declare const buildTable: ({ adapter, baseColumns, baseExtraConfig,
|
32
|
+
export declare const buildTable: ({ adapter, baseColumns, baseExtraConfig, disableNotNull, disableUnique, fields, rootRelationsToBuild, rootRelationships, rootTableIDColType, rootTableName: incomingRootTableName, tableName, timestamps, versions, }: Args) => Result;
|
29
33
|
export {};
|
30
34
|
//# sourceMappingURL=build.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/schema/build.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAEf,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/schema/build.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAEf,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAgBpC,OAAO,KAAK,EAAE,cAAc,EAAwB,eAAe,EAAE,MAAM,aAAa,CAAA;AAMxF,MAAM,MAAM,eAAe,GAAG,MAAM,CAClC,MAAM,EACN,CAAC,IAAI,EAAE,cAAc,KAAK,iBAAiB,GAAG,YAAY,GAAG,uBAAuB,CACrF,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,CAAC,CAAA;AAEnG,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC7C,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,cAAc,EAAE,OAAO,CAAA;IACvB,aAAa,EAAE,OAAO,CAAA;IACtB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,oBAAoB,CAAC,EAAE,WAAW,CAAA;IAClC,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC/B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,MAAM,GAAG;IACZ,kBAAkB,EAAE,OAAO,GAAG,OAAO,CAAA;IACrC,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAA;IACnC,gBAAgB,EAAE,WAAW,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,UAAU,0NAcpB,IAAI,KAAG,MAqYT,CAAA"}
|
package/dist/schema/build.js
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */ import {
|
1
|
+
/* eslint-disable no-param-reassign */ import { createTableName } from '@payloadcms/drizzle';
|
2
|
+
import { relations } from 'drizzle-orm';
|
2
3
|
import { foreignKey, index, integer, numeric, serial, timestamp, unique, varchar } from 'drizzle-orm/pg-core';
|
3
4
|
import toSnakeCase from 'to-snake-case';
|
4
|
-
import { createTableName } from './createTableName.js';
|
5
5
|
import { parentIDColumnMap } from './parentIDColumnMap.js';
|
6
6
|
import { setColumnID } from './setColumnID.js';
|
7
7
|
import { traverseFields } from './traverseFields.js';
|
8
|
-
export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {},
|
8
|
+
export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, disableNotNull, disableUnique = false, fields, rootRelationsToBuild, rootRelationships, rootTableIDColType, rootTableName: incomingRootTableName, tableName, timestamps, versions })=>{
|
9
|
+
const isRoot = !incomingRootTableName;
|
9
10
|
const rootTableName = incomingRootTableName || tableName;
|
10
11
|
const columns = baseColumns;
|
11
12
|
const indexes = {};
|
@@ -26,9 +27,6 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
26
27
|
});
|
27
28
|
const { hasLocalizedField, hasLocalizedManyNumberField, hasLocalizedManyTextField, hasLocalizedRelationshipField, hasManyNumberField, hasManyTextField } = traverseFields({
|
28
29
|
adapter,
|
29
|
-
buildNumbers,
|
30
|
-
buildRelationships,
|
31
|
-
buildTexts,
|
32
30
|
columns,
|
33
31
|
disableNotNull,
|
34
32
|
disableUnique,
|
@@ -45,6 +43,16 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
45
43
|
rootTableName,
|
46
44
|
versions
|
47
45
|
});
|
46
|
+
// split the relationsToBuild by localized and non-localized
|
47
|
+
const localizedRelations = new Map();
|
48
|
+
const nonLocalizedRelations = new Map();
|
49
|
+
relationsToBuild.forEach(({ type, localized, target }, key)=>{
|
50
|
+
const map = localized ? localizedRelations : nonLocalizedRelations;
|
51
|
+
map.set(key, {
|
52
|
+
type,
|
53
|
+
target
|
54
|
+
});
|
55
|
+
});
|
48
56
|
if (timestamps) {
|
49
57
|
columns.createdAt = timestamp('created_at', {
|
50
58
|
mode: 'string',
|
@@ -69,7 +77,7 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
69
77
|
return result;
|
70
78
|
});
|
71
79
|
adapter.tables[tableName] = table;
|
72
|
-
if (hasLocalizedField) {
|
80
|
+
if (hasLocalizedField || localizedRelations.size) {
|
73
81
|
const localeTableName = `${tableName}${adapter.localesSuffix}`;
|
74
82
|
localesColumns.id = serial('id').primaryKey();
|
75
83
|
localesColumns._locale = adapter.enums.enum__locales('_locale').notNull();
|
@@ -92,111 +100,132 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
92
100
|
});
|
93
101
|
});
|
94
102
|
adapter.tables[localeTableName] = localesTable;
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
103
|
+
adapter.relations[`relations_${localeTableName}`] = relations(localesTable, ({ many, one })=>{
|
104
|
+
const result = {};
|
105
|
+
result._parentID = one(table, {
|
106
|
+
fields: [
|
107
|
+
localesTable._parentID
|
108
|
+
],
|
109
|
+
references: [
|
110
|
+
table.id
|
111
|
+
],
|
112
|
+
// name the relationship by what the many() relationName is
|
113
|
+
relationName: '_locales'
|
114
|
+
});
|
115
|
+
localizedRelations.forEach(({ type, target }, key)=>{
|
116
|
+
if (type === 'one') {
|
117
|
+
result[key] = one(adapter.tables[target], {
|
118
|
+
fields: [
|
119
|
+
localesTable[key]
|
120
|
+
],
|
121
|
+
references: [
|
122
|
+
adapter.tables[target].id
|
123
|
+
],
|
124
|
+
relationName: key
|
125
|
+
});
|
126
|
+
}
|
127
|
+
if (type === 'many') {
|
128
|
+
result[key] = many(adapter.tables[target], {
|
129
|
+
relationName: key
|
130
|
+
});
|
131
|
+
}
|
132
|
+
});
|
133
|
+
return result;
|
134
|
+
});
|
106
135
|
}
|
107
|
-
if (
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
if (hasLocalizedManyTextField) {
|
117
|
-
columns.locale = adapter.enums.enum__locales('locale');
|
118
|
-
}
|
119
|
-
textsTable = adapter.pgSchema.table(textsTableName, columns, (cols)=>{
|
120
|
-
const config = {
|
121
|
-
orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent),
|
122
|
-
parentFk: foreignKey({
|
123
|
-
name: `${textsTableName}_parent_fk`,
|
124
|
-
columns: [
|
125
|
-
cols.parent
|
126
|
-
],
|
127
|
-
foreignColumns: [
|
128
|
-
table.id
|
129
|
-
]
|
130
|
-
}).onDelete('cascade')
|
136
|
+
if (isRoot) {
|
137
|
+
if (hasManyTextField) {
|
138
|
+
const textsTableName = `${rootTableName}_texts`;
|
139
|
+
const columns = {
|
140
|
+
id: serial('id').primaryKey(),
|
141
|
+
order: integer('order').notNull(),
|
142
|
+
parent: parentIDColumnMap[idColType]('parent_id').notNull(),
|
143
|
+
path: varchar('path').notNull(),
|
144
|
+
text: varchar('text')
|
131
145
|
};
|
132
|
-
if (hasManyTextField === 'index') {
|
133
|
-
config.text_idx = index(`${textsTableName}_text_idx`).on(cols.text);
|
134
|
-
}
|
135
146
|
if (hasLocalizedManyTextField) {
|
136
|
-
|
147
|
+
columns.locale = adapter.enums.enum__locales('locale');
|
137
148
|
}
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
149
|
+
textsTable = adapter.pgSchema.table(textsTableName, columns, (cols)=>{
|
150
|
+
const config = {
|
151
|
+
orderParentIdx: index(`${textsTableName}_order_parent_idx`).on(cols.order, cols.parent),
|
152
|
+
parentFk: foreignKey({
|
153
|
+
name: `${textsTableName}_parent_fk`,
|
154
|
+
columns: [
|
155
|
+
cols.parent
|
156
|
+
],
|
157
|
+
foreignColumns: [
|
158
|
+
table.id
|
159
|
+
]
|
160
|
+
}).onDelete('cascade')
|
161
|
+
};
|
162
|
+
if (hasManyTextField === 'index') {
|
163
|
+
config.text_idx = index(`${textsTableName}_text_idx`).on(cols.text);
|
164
|
+
}
|
165
|
+
if (hasLocalizedManyTextField) {
|
166
|
+
config.localeParent = index(`${textsTableName}_locale_parent`).on(cols.locale, cols.parent);
|
167
|
+
}
|
168
|
+
return config;
|
169
|
+
});
|
170
|
+
adapter.tables[textsTableName] = textsTable;
|
171
|
+
adapter.relations[`relations_${textsTableName}`] = relations(textsTable, ({ one })=>({
|
172
|
+
parent: one(table, {
|
173
|
+
fields: [
|
174
|
+
textsTable.parent
|
175
|
+
],
|
176
|
+
references: [
|
177
|
+
table.id
|
178
|
+
],
|
179
|
+
relationName: '_texts'
|
180
|
+
})
|
181
|
+
}));
|
164
182
|
}
|
165
|
-
|
166
|
-
const
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
foreignColumns: [
|
174
|
-
table.id
|
175
|
-
]
|
176
|
-
}).onDelete('cascade')
|
183
|
+
if (hasManyNumberField) {
|
184
|
+
const numbersTableName = `${rootTableName}_numbers`;
|
185
|
+
const columns = {
|
186
|
+
id: serial('id').primaryKey(),
|
187
|
+
number: numeric('number'),
|
188
|
+
order: integer('order').notNull(),
|
189
|
+
parent: parentIDColumnMap[idColType]('parent_id').notNull(),
|
190
|
+
path: varchar('path').notNull()
|
177
191
|
};
|
178
|
-
if (hasManyNumberField === 'index') {
|
179
|
-
config.numberIdx = index(`${numbersTableName}_number_idx`).on(cols.number);
|
180
|
-
}
|
181
192
|
if (hasLocalizedManyNumberField) {
|
182
|
-
|
193
|
+
columns.locale = adapter.enums.enum__locales('locale');
|
183
194
|
}
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
195
|
+
numbersTable = adapter.pgSchema.table(numbersTableName, columns, (cols)=>{
|
196
|
+
const config = {
|
197
|
+
orderParentIdx: index(`${numbersTableName}_order_parent_idx`).on(cols.order, cols.parent),
|
198
|
+
parentFk: foreignKey({
|
199
|
+
name: `${numbersTableName}_parent_fk`,
|
200
|
+
columns: [
|
201
|
+
cols.parent
|
202
|
+
],
|
203
|
+
foreignColumns: [
|
204
|
+
table.id
|
205
|
+
]
|
206
|
+
}).onDelete('cascade')
|
207
|
+
};
|
208
|
+
if (hasManyNumberField === 'index') {
|
209
|
+
config.numberIdx = index(`${numbersTableName}_number_idx`).on(cols.number);
|
210
|
+
}
|
211
|
+
if (hasLocalizedManyNumberField) {
|
212
|
+
config.localeParent = index(`${numbersTableName}_locale_parent`).on(cols.locale, cols.parent);
|
213
|
+
}
|
214
|
+
return config;
|
215
|
+
});
|
216
|
+
adapter.tables[numbersTableName] = numbersTable;
|
217
|
+
adapter.relations[`relations_${numbersTableName}`] = relations(numbersTable, ({ one })=>({
|
218
|
+
parent: one(table, {
|
219
|
+
fields: [
|
220
|
+
numbersTable.parent
|
221
|
+
],
|
222
|
+
references: [
|
223
|
+
table.id
|
224
|
+
],
|
225
|
+
relationName: '_numbers'
|
226
|
+
})
|
227
|
+
}));
|
228
|
+
}
|
200
229
|
if (relationships.size) {
|
201
230
|
const relationshipColumns = {
|
202
231
|
id: serial('id').primaryKey(),
|
@@ -255,7 +284,7 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
255
284
|
return result;
|
256
285
|
});
|
257
286
|
adapter.tables[relationshipsTableName] = relationshipsTable;
|
258
|
-
|
287
|
+
adapter.relations[`relations_${relationshipsTableName}`] = relations(relationshipsTable, ({ one })=>{
|
259
288
|
const result = {
|
260
289
|
parent: one(table, {
|
261
290
|
fields: [
|
@@ -280,27 +309,48 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
280
309
|
],
|
281
310
|
references: [
|
282
311
|
adapter.tables[relatedTableName].id
|
283
|
-
]
|
312
|
+
],
|
313
|
+
relationName: relationTo
|
284
314
|
});
|
285
315
|
});
|
286
316
|
return result;
|
287
317
|
});
|
288
|
-
adapter.relations[`relations_${relationshipsTableName}`] = relationshipsTableRelations;
|
289
318
|
}
|
290
319
|
}
|
291
|
-
|
320
|
+
adapter.relations[`relations_${tableName}`] = relations(table, ({ many, one })=>{
|
292
321
|
const result = {};
|
293
|
-
|
294
|
-
|
322
|
+
nonLocalizedRelations.forEach(({ type, target }, key)=>{
|
323
|
+
if (type === 'one') {
|
324
|
+
result[key] = one(adapter.tables[target], {
|
325
|
+
fields: [
|
326
|
+
table[key]
|
327
|
+
],
|
328
|
+
references: [
|
329
|
+
adapter.tables[target].id
|
330
|
+
],
|
331
|
+
relationName: key
|
332
|
+
});
|
333
|
+
}
|
334
|
+
if (type === 'many') {
|
335
|
+
result[key] = many(adapter.tables[target], {
|
336
|
+
relationName: key
|
337
|
+
});
|
338
|
+
}
|
295
339
|
});
|
296
340
|
if (hasLocalizedField) {
|
297
|
-
result._locales = many(localesTable
|
341
|
+
result._locales = many(localesTable, {
|
342
|
+
relationName: '_locales'
|
343
|
+
});
|
298
344
|
}
|
299
345
|
if (hasManyTextField) {
|
300
|
-
result._texts = many(textsTable
|
346
|
+
result._texts = many(textsTable, {
|
347
|
+
relationName: '_texts'
|
348
|
+
});
|
301
349
|
}
|
302
350
|
if (hasManyNumberField) {
|
303
|
-
result._numbers = many(numbersTable
|
351
|
+
result._numbers = many(numbersTable, {
|
352
|
+
relationName: '_numbers'
|
353
|
+
});
|
304
354
|
}
|
305
355
|
if (relationships.size && relationshipsTable) {
|
306
356
|
result._rels = many(relationshipsTable, {
|
@@ -309,7 +359,6 @@ export const buildTable = ({ adapter, baseColumns = {}, baseExtraConfig = {}, bu
|
|
309
359
|
}
|
310
360
|
return result;
|
311
361
|
});
|
312
|
-
adapter.relations[`relations_${tableName}`] = tableRelations;
|
313
362
|
return {
|
314
363
|
hasManyNumberField,
|
315
364
|
hasManyTextField,
|