@payloadcms/drizzle 4.0.0-internal.9496957 → 4.0.0-internal.952ed66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/count.d.ts.map +1 -1
- package/dist/count.js +25 -3
- package/dist/count.js.map +1 -1
- package/dist/countGlobalVersions.js +8 -3
- package/dist/countGlobalVersions.js.map +1 -1
- package/dist/countVersions.d.ts.map +1 -1
- package/dist/countVersions.js +29 -4
- package/dist/countVersions.js.map +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +17 -2
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +12 -1
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteBranchGlobal.d.ts +10 -0
- package/dist/deleteBranchGlobal.d.ts.map +1 -0
- package/dist/deleteBranchGlobal.js +27 -0
- package/dist/deleteBranchGlobal.js.map +1 -0
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +25 -1
- package/dist/deleteOne.js.map +1 -1
- package/dist/exports/postgres.d.ts +2 -1
- package/dist/exports/postgres.d.ts.map +1 -1
- package/dist/exports/postgres.js +2 -1
- package/dist/exports/postgres.js.map +1 -1
- package/dist/exports/sqlite.d.ts +2 -1
- package/dist/exports/sqlite.d.ts.map +1 -1
- package/dist/exports/sqlite.js +2 -1
- package/dist/exports/sqlite.js.map +1 -1
- package/dist/find/buildFindManyArgs.d.ts +3 -2
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/buildFindManyArgs.js +2 -1
- package/dist/find/buildFindManyArgs.js.map +1 -1
- package/dist/find/buildPolymorphicJoinQuery.d.ts +40 -0
- package/dist/find/buildPolymorphicJoinQuery.d.ts.map +1 -0
- package/dist/find/buildPolymorphicJoinQuery.js +163 -0
- package/dist/find/buildPolymorphicJoinQuery.js.map +1 -0
- package/dist/find/buildPolymorphicJoinWhere.d.ts +20 -0
- package/dist/find/buildPolymorphicJoinWhere.d.ts.map +1 -0
- package/dist/find/buildPolymorphicJoinWhere.js +301 -0
- package/dist/find/buildPolymorphicJoinWhere.js.map +1 -0
- package/dist/find/createPolymorphicJoinWherePlan.d.ts +38 -0
- package/dist/find/createPolymorphicJoinWherePlan.d.ts.map +1 -0
- package/dist/find/createPolymorphicJoinWherePlan.js +200 -0
- package/dist/find/createPolymorphicJoinWherePlan.js.map +1 -0
- package/dist/find/findMany.d.ts +6 -1
- package/dist/find/findMany.d.ts.map +1 -1
- package/dist/find/findMany.js +16 -3
- package/dist/find/findMany.js.map +1 -1
- package/dist/find/traverseFields.d.ts +3 -2
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +82 -198
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +32 -4
- package/dist/find.js.map +1 -1
- package/dist/findDistinct.d.ts.map +1 -1
- package/dist/findDistinct.js +104 -8
- package/dist/findDistinct.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +24 -5
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.js +8 -3
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +30 -3
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +32 -5
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts +3 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -8
- package/dist/index.js.map +1 -1
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +6 -2
- package/dist/migrate.js.map +1 -1
- package/dist/migrateDown.d.ts.map +1 -1
- package/dist/migrateDown.js +5 -2
- package/dist/migrateDown.js.map +1 -1
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js +5 -2
- package/dist/migrateFresh.js.map +1 -1
- package/dist/migrateRefresh.d.ts.map +1 -1
- package/dist/migrateRefresh.js +6 -2
- package/dist/migrateRefresh.js.map +1 -1
- package/dist/migrateReset.d.ts.map +1 -1
- package/dist/migrateReset.js +6 -2
- package/dist/migrateReset.js.map +1 -1
- package/dist/postgres/createJSONQuery/index.js +3 -3
- package/dist/postgres/createJSONQuery/index.js.map +1 -1
- package/dist/postgres/insert.d.ts.map +1 -1
- package/dist/postgres/insert.js +4 -2
- package/dist/postgres/insert.js.map +1 -1
- package/dist/postgres/predefinedMigrations/sizes-to-variants/index.d.ts +35 -0
- package/dist/postgres/predefinedMigrations/sizes-to-variants/index.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/sizes-to-variants/index.js +185 -0
- package/dist/postgres/predefinedMigrations/sizes-to-variants/index.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.js +8 -4
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/index.js +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/index.js.map +1 -1
- package/dist/postgres/requireDrizzleKit.d.ts +4 -0
- package/dist/postgres/requireDrizzleKit.d.ts.map +1 -1
- package/dist/postgres/requireDrizzleKit.js +16 -10
- package/dist/postgres/requireDrizzleKit.js.map +1 -1
- package/dist/postgres/types.d.ts +4 -0
- package/dist/postgres/types.d.ts.map +1 -1
- package/dist/postgres/types.js.map +1 -1
- package/dist/queries/buildAndOrConditions.d.ts +3 -2
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +2 -1
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildBranchVisibility.d.ts +11 -0
- package/dist/queries/buildBranchVisibility.d.ts.map +1 -0
- package/dist/queries/buildBranchVisibility.js +48 -0
- package/dist/queries/buildBranchVisibility.js.map +1 -0
- package/dist/queries/buildOrderBy.d.ts +3 -2
- package/dist/queries/buildOrderBy.d.ts.map +1 -1
- package/dist/queries/buildOrderBy.js +2 -1
- package/dist/queries/buildOrderBy.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +3 -2
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +4 -2
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts +3 -2
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +176 -29
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/parseParams.d.ts +3 -2
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +63 -3
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +27 -5
- package/dist/queryDrafts.js.map +1 -1
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +28 -20
- package/dist/schema/build.js.map +1 -1
- package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.js +3 -2
- package/dist/sqlite/createJSONQuery/convertPathToJSONTraversal.js.map +1 -1
- package/dist/sqlite/createJSONQuery/index.d.ts.map +1 -1
- package/dist/sqlite/createJSONQuery/index.js +6 -5
- package/dist/sqlite/createJSONQuery/index.js.map +1 -1
- package/dist/sqlite/createRequireDrizzleKit.d.ts +6 -0
- package/dist/sqlite/createRequireDrizzleKit.d.ts.map +1 -0
- package/dist/sqlite/createRequireDrizzleKit.js +15 -0
- package/dist/sqlite/createRequireDrizzleKit.js.map +1 -0
- package/dist/sqlite/execute.js.map +1 -1
- package/dist/sqlite/insert.d.ts.map +1 -1
- package/dist/sqlite/insert.js +9 -4
- package/dist/sqlite/insert.js.map +1 -1
- package/dist/sqlite/predefinedMigrations/sizes-to-variants/index.d.ts +15 -0
- package/dist/sqlite/predefinedMigrations/sizes-to-variants/index.d.ts.map +1 -0
- package/dist/sqlite/predefinedMigrations/sizes-to-variants/index.js +114 -0
- package/dist/sqlite/predefinedMigrations/sizes-to-variants/index.js.map +1 -0
- package/dist/sqlite/types.d.ts +4 -0
- package/dist/sqlite/types.d.ts.map +1 -1
- package/dist/sqlite/types.js.map +1 -1
- package/dist/transactions/beginTransaction.d.ts.map +1 -1
- package/dist/transactions/beginTransaction.js +13 -5
- package/dist/transactions/beginTransaction.js.map +1 -1
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js +2 -5
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/transform/read/traverseFields.js.map +1 -1
- package/dist/transform/write/array.d.ts +3 -2
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/array.js +2 -1
- package/dist/transform/write/array.js.map +1 -1
- package/dist/transform/write/blocks.d.ts +3 -2
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/blocks.js +2 -1
- package/dist/transform/write/blocks.js.map +1 -1
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/index.js +2 -0
- package/dist/transform/write/index.js.map +1 -1
- package/dist/transform/write/traverseFields.d.ts +2 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +51 -21
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/transform/write/types.d.ts +7 -0
- package/dist/transform/write/types.d.ts.map +1 -1
- package/dist/transform/write/types.js.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/updateGlobal.d.ts +5 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +96 -4
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +93 -4
- package/dist/updateOne.js.map +1 -1
- package/dist/upsertBranchGlobalChange.d.ts +3 -0
- package/dist/upsertBranchGlobalChange.d.ts.map +1 -0
- package/dist/upsertBranchGlobalChange.js +35 -0
- package/dist/upsertBranchGlobalChange.js.map +1 -0
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.js +17 -12
- package/dist/upsertRow/deleteExistingRowsByPath.js.map +1 -1
- package/dist/upsertRow/index.d.ts +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +156 -46
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/types.d.ts +3 -0
- package/dist/upsertRow/types.d.ts.map +1 -1
- package/dist/upsertRow/types.js.map +1 -1
- package/dist/utilities/blocksToJsonMigrator.d.ts.map +1 -1
- package/dist/utilities/blocksToJsonMigrator.js +7 -18
- package/dist/utilities/blocksToJsonMigrator.js.map +1 -1
- package/dist/utilities/buildCreateMigration.js +1 -1
- package/dist/utilities/buildCreateMigration.js.map +1 -1
- package/dist/utilities/buildDynamicPredefinedSizesToVariantsMigration.d.ts +15 -0
- package/dist/utilities/buildDynamicPredefinedSizesToVariantsMigration.d.ts.map +1 -0
- package/dist/utilities/buildDynamicPredefinedSizesToVariantsMigration.js +110 -0
- package/dist/utilities/buildDynamicPredefinedSizesToVariantsMigration.js.map +1 -0
- package/dist/utilities/createSchemaGenerator.d.ts.map +1 -1
- package/dist/utilities/createSchemaGenerator.js +7 -12
- package/dist/utilities/createSchemaGenerator.js.map +1 -1
- package/dist/utilities/executeSchemaHooks.js +1 -1
- package/dist/utilities/executeSchemaHooks.js.map +1 -1
- package/dist/utilities/formatGeneratedFile.d.ts +10 -0
- package/dist/utilities/formatGeneratedFile.d.ts.map +1 -0
- package/dist/utilities/formatGeneratedFile.js +58 -0
- package/dist/utilities/formatGeneratedFile.js.map +1 -0
- package/dist/utilities/getSizesToVariantsRenames.d.ts +54 -0
- package/dist/utilities/getSizesToVariantsRenames.d.ts.map +1 -0
- package/dist/utilities/getSizesToVariantsRenames.js +251 -0
- package/dist/utilities/getSizesToVariantsRenames.js.map +1 -0
- package/dist/utilities/getTransaction.js.map +1 -1
- package/dist/utilities/parseJSONPathSegment.d.ts +9 -0
- package/dist/utilities/parseJSONPathSegment.d.ts.map +1 -0
- package/dist/utilities/parseJSONPathSegment.js +17 -0
- package/dist/utilities/parseJSONPathSegment.js.map +1 -0
- package/dist/utilities/pushDevSchema.js +1 -1
- package/dist/utilities/pushDevSchema.js.map +1 -1
- package/package.json +17 -19
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.spec.js +0 -91
- package/dist/postgres/query/assertOperatorHandlerExtensionsInstalled.spec.js.map +0 -1
- package/dist/postgres/query/postgresUnaccent.spec.js +0 -71
- package/dist/postgres/query/postgresUnaccent.spec.js.map +0 -1
- package/dist/queries/buildOperatorConstraint.spec.js +0 -348
- package/dist/queries/buildOperatorConstraint.spec.js.map +0 -1
- package/dist/queries/validateOperatorHandlers.spec.js +0 -142
- package/dist/queries/validateOperatorHandlers.spec.js.map +0 -1
- package/dist/schema/buildRawSchema.spec.js +0 -290
- package/dist/schema/buildRawSchema.spec.js.map +0 -1
- package/dist/sqlite/requireDrizzleKit.d.ts +0 -3
- package/dist/sqlite/requireDrizzleKit.d.ts.map +0 -1
- package/dist/sqlite/requireDrizzleKit.js +0 -12
- package/dist/sqlite/requireDrizzleKit.js.map +0 -1
- package/dist/upsertRow/handleUpsertError.spec.js +0 -42
- package/dist/upsertRow/handleUpsertError.spec.js.map +0 -1
- package/dist/utilities/checkTruncatedIdentifiers.spec.js +0 -301
- package/dist/utilities/checkTruncatedIdentifiers.spec.js.map +0 -1
- package/dist/utilities/isValidStringID.spec.js +0 -15
- package/dist/utilities/isValidStringID.spec.js.map +0 -1
- package/dist/utilities/validateIdentifierLength.spec.js +0 -19
- package/dist/utilities/validateIdentifierLength.spec.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { createGlobal } from './createGlobal.js';
|
|
|
6
6
|
export { createGlobalVersion } from './createGlobalVersion.js';
|
|
7
7
|
export { createTableName } from './createTableName.js';
|
|
8
8
|
export { createVersion } from './createVersion.js';
|
|
9
|
+
export { deleteBranchGlobal } from './deleteBranchGlobal.js';
|
|
9
10
|
export { deleteMany } from './deleteMany.js';
|
|
10
11
|
export { deleteOne } from './deleteOne.js';
|
|
11
12
|
export { deleteVersions } from './deleteVersions.js';
|
|
@@ -39,9 +40,11 @@ export { updateMany } from './updateMany.js';
|
|
|
39
40
|
export { updateOne } from './updateOne.js';
|
|
40
41
|
export { updateVersion } from './updateVersion.js';
|
|
41
42
|
export { upsert } from './upsert.js';
|
|
43
|
+
export { upsertBranchGlobalChange } from './upsertBranchGlobalChange.js';
|
|
42
44
|
export { upsertRow } from './upsertRow/index.js';
|
|
43
45
|
export { buildDynamicPredefinedBlocksToJsonMigration, createBlocksToJsonMigrator, getBlocksToJsonMigrator } from './utilities/blocksToJsonMigrator.js';
|
|
44
46
|
export { buildCreateMigration } from './utilities/buildCreateMigration.js';
|
|
47
|
+
export { buildDynamicPredefinedSizesToVariantsMigration } from './utilities/buildDynamicPredefinedSizesToVariantsMigration.js';
|
|
45
48
|
export { buildIndexName } from './utilities/buildIndexName.js';
|
|
46
49
|
export { createSchemaGenerator } from './utilities/createSchemaGenerator.js';
|
|
47
50
|
export { executeSchemaHooks } from './utilities/executeSchemaHooks.js';
|
|
@@ -49,13 +52,5 @@ export { extendDrizzleTable } from './utilities/extendDrizzleTable.js';
|
|
|
49
52
|
export { hasLocalesTable } from './utilities/hasLocalesTable.js';
|
|
50
53
|
export { pushDevSchema } from './utilities/pushDevSchema.js';
|
|
51
54
|
export { validateExistingBlockIsIdentical } from './utilities/validateExistingBlockIsIdentical.js';
|
|
52
|
-
import { findMigrationDir as payloadFindMigrationDir } from 'payload';
|
|
53
|
-
/**
|
|
54
|
-
* @deprecated remove in 4.0
|
|
55
|
-
* use
|
|
56
|
-
* ```ts
|
|
57
|
-
* import { findMigrationDir } from 'payload'
|
|
58
|
-
* ```
|
|
59
|
-
*/ export const findMigrationDir = payloadFindMigrationDir;
|
|
60
55
|
|
|
61
56
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { count } from './count.js'\nexport { countGlobalVersions } from './countGlobalVersions.js'\nexport { countVersions } from './countVersions.js'\nexport { create } from './create.js'\nexport { createGlobal } from './createGlobal.js'\nexport { createGlobalVersion } from './createGlobalVersion.js'\nexport { createTableName } from './createTableName.js'\nexport { createVersion } from './createVersion.js'\nexport { deleteMany } from './deleteMany.js'\nexport { deleteOne } from './deleteOne.js'\nexport { deleteVersions } from './deleteVersions.js'\nexport { destroy } from './destroy.js'\nexport { find } from './find.js'\nexport { findDistinct } from './findDistinct.js'\nexport { findGlobal } from './findGlobal.js'\nexport { findGlobalVersions } from './findGlobalVersions.js'\nexport { findOne } from './findOne.js'\nexport { findVersions } from './findVersions.js'\nexport { migrate } from './migrate.js'\nexport { migrateDown } from './migrateDown.js'\nexport { migrateFresh } from './migrateFresh.js'\nexport { migrateRefresh } from './migrateRefresh.js'\nexport { migrateReset } from './migrateReset.js'\nexport { migrateStatus } from './migrateStatus.js'\nexport { buildQuery } from './queries/buildQuery.js'\nexport { operatorMap } from './queries/operatorMap.js'\nexport type { DrizzleResolvedOperator, Operators } from './queries/operatorMap.js'\nexport { parseParams } from './queries/parseParams.js'\nexport { validateOperatorHandlers } from './queries/validateOperatorHandlers.js'\nexport { queryDrafts } from './queryDrafts.js'\nexport { buildDrizzleRelations } from './schema/buildDrizzleRelations.js'\nexport { buildRawSchema } from './schema/buildRawSchema.js'\nexport { beginTransaction } from './transactions/beginTransaction.js'\nexport { commitTransaction } from './transactions/commitTransaction.js'\nexport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nexport type {\n BaseRawColumn,\n BlocksToJsonMigrator,\n BuildDrizzleTable,\n BuildQueryJoinAliases,\n ColumnToCodeConverter,\n CountDistinct,\n CreateJSONQueryArgs,\n DeleteWhere,\n DrizzleAdapter,\n DrizzleOperandTransformHandler,\n DrizzleOperatorHandler,\n DrizzleOperatorHandlerContext,\n DrizzleOperatorReplacementHandler,\n DrizzleQueryConfig,\n DrizzleTransaction,\n DropDatabase,\n EnumRawColumn,\n Execute,\n GenericColumn,\n GenericColumns,\n GenericPgColumn,\n GenericRelation,\n GenericTable,\n IDType,\n Insert,\n IntegerRawColumn,\n Migration,\n PostgresDB,\n RawColumn,\n RawForeignKey,\n RawIndex,\n RawRelation,\n RawTable,\n RelationMap,\n RequireDrizzleKit,\n SetColumnID,\n SQLiteDB,\n TimestampRawColumn,\n TransactionPg,\n TransactionSQLite,\n UUIDRawColumn,\n VectorRawColumn,\n} from './types.js'\nexport { updateGlobal } from './updateGlobal.js'\nexport { updateGlobalVersion } from './updateGlobalVersion.js'\nexport { updateJobs } from './updateJobs.js'\nexport { updateMany } from './updateMany.js'\nexport { updateOne } from './updateOne.js'\nexport { updateVersion } from './updateVersion.js'\nexport { upsert } from './upsert.js'\nexport { upsertRow } from './upsertRow/index.js'\nexport {\n buildDynamicPredefinedBlocksToJsonMigration,\n createBlocksToJsonMigrator,\n getBlocksToJsonMigrator,\n} from './utilities/blocksToJsonMigrator.js'\nexport { buildCreateMigration } from './utilities/buildCreateMigration.js'\nexport { buildIndexName } from './utilities/buildIndexName.js'\nexport { createSchemaGenerator } from './utilities/createSchemaGenerator.js'\nexport { executeSchemaHooks } from './utilities/executeSchemaHooks.js'\nexport { extendDrizzleTable } from './utilities/extendDrizzleTable.js'\nexport { hasLocalesTable } from './utilities/hasLocalesTable.js'\nexport { pushDevSchema } from './utilities/pushDevSchema.js'\nexport { validateExistingBlockIsIdentical } from './utilities/validateExistingBlockIsIdentical.js'\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { count } from './count.js'\nexport { countGlobalVersions } from './countGlobalVersions.js'\nexport { countVersions } from './countVersions.js'\nexport { create } from './create.js'\nexport { createGlobal } from './createGlobal.js'\nexport { createGlobalVersion } from './createGlobalVersion.js'\nexport { createTableName } from './createTableName.js'\nexport { createVersion } from './createVersion.js'\nexport { deleteBranchGlobal } from './deleteBranchGlobal.js'\nexport { deleteMany } from './deleteMany.js'\nexport { deleteOne } from './deleteOne.js'\nexport { deleteVersions } from './deleteVersions.js'\nexport { destroy } from './destroy.js'\nexport { find } from './find.js'\nexport { findDistinct } from './findDistinct.js'\nexport { findGlobal } from './findGlobal.js'\nexport { findGlobalVersions } from './findGlobalVersions.js'\nexport { findOne } from './findOne.js'\nexport { findVersions } from './findVersions.js'\nexport { migrate } from './migrate.js'\nexport { migrateDown } from './migrateDown.js'\nexport { migrateFresh } from './migrateFresh.js'\nexport { migrateRefresh } from './migrateRefresh.js'\nexport { migrateReset } from './migrateReset.js'\nexport { migrateStatus } from './migrateStatus.js'\nexport { buildQuery } from './queries/buildQuery.js'\nexport { operatorMap } from './queries/operatorMap.js'\nexport type { DrizzleResolvedOperator, Operators } from './queries/operatorMap.js'\nexport { parseParams } from './queries/parseParams.js'\nexport { validateOperatorHandlers } from './queries/validateOperatorHandlers.js'\nexport { queryDrafts } from './queryDrafts.js'\nexport { buildDrizzleRelations } from './schema/buildDrizzleRelations.js'\nexport { buildRawSchema } from './schema/buildRawSchema.js'\nexport { beginTransaction } from './transactions/beginTransaction.js'\nexport { commitTransaction } from './transactions/commitTransaction.js'\nexport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nexport type {\n BaseRawColumn,\n BlocksToJsonMigrator,\n BuildDrizzleTable,\n BuildQueryJoinAliases,\n ColumnToCodeConverter,\n CountDistinct,\n CreateJSONQueryArgs,\n DeleteWhere,\n DrizzleAdapter,\n DrizzleOperandTransformHandler,\n DrizzleOperatorHandler,\n DrizzleOperatorHandlerContext,\n DrizzleOperatorReplacementHandler,\n DrizzleQueryConfig,\n DrizzleTransaction,\n DropDatabase,\n EnumRawColumn,\n Execute,\n GenericColumn,\n GenericColumns,\n GenericPgColumn,\n GenericRelation,\n GenericTable,\n IDType,\n Insert,\n IntegerRawColumn,\n Migration,\n PostgresDB,\n RawColumn,\n RawForeignKey,\n RawIndex,\n RawRelation,\n RawTable,\n RelationMap,\n RequireDrizzleKit,\n SetColumnID,\n SQLiteDB,\n TimestampRawColumn,\n TransactionPg,\n TransactionSQLite,\n UUIDRawColumn,\n VectorRawColumn,\n} from './types.js'\nexport { updateGlobal } from './updateGlobal.js'\nexport { updateGlobalVersion } from './updateGlobalVersion.js'\nexport { updateJobs } from './updateJobs.js'\nexport { updateMany } from './updateMany.js'\nexport { updateOne } from './updateOne.js'\nexport { updateVersion } from './updateVersion.js'\nexport { upsert } from './upsert.js'\nexport { upsertBranchGlobalChange } from './upsertBranchGlobalChange.js'\nexport { upsertRow } from './upsertRow/index.js'\nexport {\n buildDynamicPredefinedBlocksToJsonMigration,\n createBlocksToJsonMigrator,\n getBlocksToJsonMigrator,\n} from './utilities/blocksToJsonMigrator.js'\nexport { buildCreateMigration } from './utilities/buildCreateMigration.js'\nexport { buildDynamicPredefinedSizesToVariantsMigration } from './utilities/buildDynamicPredefinedSizesToVariantsMigration.js'\nexport { buildIndexName } from './utilities/buildIndexName.js'\nexport { createSchemaGenerator } from './utilities/createSchemaGenerator.js'\nexport { executeSchemaHooks } from './utilities/executeSchemaHooks.js'\nexport { extendDrizzleTable } from './utilities/extendDrizzleTable.js'\nexport { hasLocalesTable } from './utilities/hasLocalesTable.js'\nexport { pushDevSchema } from './utilities/pushDevSchema.js'\nexport { validateExistingBlockIsIdentical } from './utilities/validateExistingBlockIsIdentical.js'\n"],"names":["count","countGlobalVersions","countVersions","create","createGlobal","createGlobalVersion","createTableName","createVersion","deleteBranchGlobal","deleteMany","deleteOne","deleteVersions","destroy","find","findDistinct","findGlobal","findGlobalVersions","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","buildQuery","operatorMap","parseParams","validateOperatorHandlers","queryDrafts","buildDrizzleRelations","buildRawSchema","beginTransaction","commitTransaction","rollbackTransaction","updateGlobal","updateGlobalVersion","updateJobs","updateMany","updateOne","updateVersion","upsert","upsertBranchGlobalChange","upsertRow","buildDynamicPredefinedBlocksToJsonMigration","createBlocksToJsonMigrator","getBlocksToJsonMigrator","buildCreateMigration","buildDynamicPredefinedSizesToVariantsMigration","buildIndexName","createSchemaGenerator","executeSchemaHooks","extendDrizzleTable","hasLocalesTable","pushDevSchema","validateExistingBlockIsIdentical"],"mappings":"AAAA,SAASA,KAAK,QAAQ,aAAY;AAClC,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,WAAW,QAAQ,2BAA0B;AAEtD,SAASC,WAAW,QAAQ,2BAA0B;AACtD,SAASC,wBAAwB,QAAQ,wCAAuC;AAChF,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,qBAAqB,QAAQ,oCAAmC;AACzE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,mBAAmB,QAAQ,wCAAuC;AA6C3E,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SACEC,2CAA2C,EAC3CC,0BAA0B,EAC1BC,uBAAuB,QAClB,sCAAqC;AAC5C,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,8CAA8C,QAAQ,gEAA+D;AAC9H,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,qBAAqB,QAAQ,uCAAsC;AAC5E,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,gCAAgC,QAAQ,kDAAiD"}
|
package/dist/migrate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,YAAY,CAAA;AAM3D,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,YAAY,CAAA;AAM3D,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,SAAS,CA+E7C,CAAA"}
|
package/dist/migrate.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { commitTransaction,
|
|
1
|
+
import { commitTransaction, createPayloadRequest, initTransaction, killTransaction, readMigrationFiles } from 'payload';
|
|
2
2
|
import prompts from 'prompts';
|
|
3
3
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
4
4
|
import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
@@ -29,6 +29,7 @@ export const migrate = async function migrate(args) {
|
|
|
29
29
|
({ docs: migrationsInDB } = await payload.find({
|
|
30
30
|
collection: 'payload-migrations',
|
|
31
31
|
limit: 0,
|
|
32
|
+
overrideAccess: true,
|
|
32
33
|
sort: '-name'
|
|
33
34
|
}));
|
|
34
35
|
if (migrationsInDB.find((m)=>m.batch === -1)) {
|
|
@@ -83,7 +84,9 @@ export const migrate = async function migrate(args) {
|
|
|
83
84
|
};
|
|
84
85
|
async function runMigrationFile(payload, migration, batch) {
|
|
85
86
|
const start = Date.now();
|
|
86
|
-
const req = await
|
|
87
|
+
const req = await createPayloadRequest({
|
|
88
|
+
payload
|
|
89
|
+
});
|
|
87
90
|
payload.logger.info({
|
|
88
91
|
msg: `Migrating: ${migration.name}`
|
|
89
92
|
});
|
|
@@ -104,6 +107,7 @@ async function runMigrationFile(payload, migration, batch) {
|
|
|
104
107
|
name: migration.name,
|
|
105
108
|
batch
|
|
106
109
|
},
|
|
110
|
+
overrideAccess: true,
|
|
107
111
|
req
|
|
108
112
|
});
|
|
109
113
|
await commitTransaction(req);
|
package/dist/migrate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/migrate.ts"],"sourcesContent":["import type { MigrationResult, Payload } from 'payload'\n\nimport {\n commitTransaction,\n
|
|
1
|
+
{"version":3,"sources":["../src/migrate.ts"],"sourcesContent":["import type { MigrationResult, Payload } from 'payload'\n\nimport {\n commitTransaction,\n createPayloadRequest,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload'\nimport prompts from 'prompts'\n\nimport type { DrizzleAdapter, Migration } from './types.js'\n\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\nimport { parseError } from './utilities/parseError.js'\n\nexport const migrate: DrizzleAdapter['migrate'] = async function migrate(\n this: DrizzleAdapter,\n args,\n) {\n const { payload } = this\n const { forceAcceptWarning = false, shouldPrompt = true } = args ?? {}\n const migrationFiles = args?.migrations || (await readMigrationFiles({ payload }))\n\n if (!migrationFiles.length) {\n payload.logger.info({ msg: 'No migrations to run.' })\n return { migrated: [], rolledBack: [] }\n }\n\n if ('createExtensions' in this && typeof this.createExtensions === 'function') {\n await this.createExtensions()\n }\n\n let latestBatch = 0\n let migrationsInDB = []\n\n const hasMigrationTable = await migrationTableExists(this)\n\n if (hasMigrationTable) {\n ;({ docs: migrationsInDB } = await payload.find({\n collection: 'payload-migrations',\n limit: 0,\n overrideAccess: true,\n sort: '-name',\n }))\n\n if (migrationsInDB.find((m) => m.batch === -1)) {\n if (!forceAcceptWarning) {\n if (!shouldPrompt) {\n return { cancelled: true, migrated: [], rolledBack: [] }\n }\n\n const { confirm: runMigrations } = await prompts({\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message:\n \"It looks like you've run Payload in dev mode, meaning you've dynamically pushed changes to your database.\\n\\n\" +\n \"If you'd like to run migrations, data loss will occur. Would you like to proceed?\",\n })\n\n if (!runMigrations) {\n return { cancelled: true, migrated: [], rolledBack: [] }\n }\n }\n // ignore the dev migration so that the latest batch number increments correctly\n migrationsInDB = migrationsInDB.filter((m) => m.batch !== -1)\n }\n\n if (Number(migrationsInDB?.[0]?.batch) > 0) {\n latestBatch = Number(migrationsInDB[0]?.batch)\n }\n }\n\n const newBatch = latestBatch + 1\n const migrated: string[] = []\n\n // Execute 'up' function for each migration sequentially\n for (const migration of migrationFiles) {\n const alreadyRan = migrationsInDB.find((existing) => existing.name === migration.name)\n\n // If already ran, skip\n if (alreadyRan) {\n continue\n }\n\n await runMigrationFile(payload, migration, newBatch)\n migrated.push(migration.name)\n }\n\n return {\n ...(migrated.length ? { batch: newBatch } : {}),\n migrated,\n rolledBack: [],\n } satisfies MigrationResult\n}\n\nasync function runMigrationFile(payload: Payload, migration: Migration, batch: number) {\n const start = Date.now()\n const req = await createPayloadRequest({ payload })\n\n payload.logger.info({ msg: `Migrating: ${migration.name}` })\n\n try {\n await initTransaction(req)\n const db = await getTransaction(payload.db as DrizzleAdapter, req)\n await migration.up({ db, payload, req })\n payload.logger.info({ msg: `Migrated: ${migration.name} (${Date.now() - start}ms)` })\n await payload.create({\n collection: 'payload-migrations',\n data: {\n name: migration.name,\n batch,\n },\n overrideAccess: true,\n req,\n })\n await commitTransaction(req)\n } catch (err: unknown) {\n await killTransaction(req)\n payload.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}`),\n })\n throw err\n }\n}\n"],"names":["commitTransaction","createPayloadRequest","initTransaction","killTransaction","readMigrationFiles","prompts","getTransaction","migrationTableExists","parseError","migrate","args","payload","forceAcceptWarning","shouldPrompt","migrationFiles","migrations","length","logger","info","msg","migrated","rolledBack","createExtensions","latestBatch","migrationsInDB","hasMigrationTable","docs","find","collection","limit","overrideAccess","sort","m","batch","cancelled","confirm","runMigrations","name","type","initial","message","filter","Number","newBatch","migration","alreadyRan","existing","runMigrationFile","push","start","Date","now","req","db","up","create","data","err","error"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,UAAS;AAChB,OAAOC,aAAa,UAAS;AAI7B,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,4BAA2B;A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C,QAAQ4C,MAAM,CAAC;YACnB3B,YAAY;YACZ4B,MAAM;gBACJnB,MAAMO,UAAUP,IAAI;gBACpBJ;YACF;YACAH,gBAAgB;YAChBsB;QACF;QACA,MAAMpD,kBAAkBoD;IAC1B,EAAE,OAAOK,KAAc;QACrB,MAAMtD,gBAAgBiD;QACtBzC,QAAQM,MAAM,CAACyC,KAAK,CAAC;YACnBD;YACAtC,KAAKX,WAAWiD,KAAK,CAAC,wBAAwB,EAAEb,UAAUP,IAAI,EAAE;QAClE;QACA,MAAMoB;IACR;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateDown.d.ts","sourceRoot":"","sources":["../src/migrateDown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAW9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD,wBAAsB,WAAW,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"migrateDown.d.ts","sourceRoot":"","sources":["../src/migrateDown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAW9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD,wBAAsB,WAAW,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CA+DhF"}
|
package/dist/migrateDown.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { commitTransaction,
|
|
1
|
+
import { commitTransaction, createPayloadRequest, getMigrations, initTransaction, killTransaction, readMigrationFiles } from 'payload';
|
|
2
2
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
3
3
|
import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
4
4
|
import { parseError } from './utilities/parseError.js';
|
|
@@ -30,7 +30,9 @@ export async function migrateDown() {
|
|
|
30
30
|
throw new Error(`Migration ${migration.name} not found locally.`);
|
|
31
31
|
}
|
|
32
32
|
const start = Date.now();
|
|
33
|
-
const req = await
|
|
33
|
+
const req = await createPayloadRequest({
|
|
34
|
+
payload
|
|
35
|
+
});
|
|
34
36
|
try {
|
|
35
37
|
payload.logger.info({
|
|
36
38
|
msg: `Migrating down: ${migrationFile.name}`
|
|
@@ -50,6 +52,7 @@ export async function migrateDown() {
|
|
|
50
52
|
await payload.delete({
|
|
51
53
|
id: migration.id,
|
|
52
54
|
collection: 'payload-migrations',
|
|
55
|
+
overrideAccess: true,
|
|
53
56
|
req
|
|
54
57
|
});
|
|
55
58
|
}
|
package/dist/migrateDown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/migrateDown.ts"],"sourcesContent":["import type { MigrationResult } from 'payload'\n\nimport {\n commitTransaction,\n
|
|
1
|
+
{"version":3,"sources":["../src/migrateDown.ts"],"sourcesContent":["import type { MigrationResult } from 'payload'\n\nimport {\n commitTransaction,\n createPayloadRequest,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\nimport { parseError } from './utilities/parseError.js'\n\nexport async function migrateDown(this: DrizzleAdapter): Promise<MigrationResult> {\n const { payload } = this\n const migrationFiles = await readMigrationFiles({ payload })\n\n const { existingMigrations, latestBatch } = await getMigrations({\n payload,\n })\n\n if (!existingMigrations?.length) {\n payload.logger.info({ msg: 'No migrations to rollback.' })\n return { migrated: [], rolledBack: [] }\n }\n\n payload.logger.info({\n msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`,\n })\n\n const latestBatchMigrations = existingMigrations.filter(({ batch }) => batch === latestBatch)\n const rolledBack: string[] = []\n\n for (const migration of latestBatchMigrations) {\n const migrationFile = migrationFiles.find((m) => m.name === migration.name)\n if (!migrationFile) {\n throw new Error(`Migration ${migration.name} not found locally.`)\n }\n\n const start = Date.now()\n const req = await createPayloadRequest({ payload })\n\n try {\n payload.logger.info({ msg: `Migrating down: ${migrationFile.name}` })\n await initTransaction(req)\n const db = await getTransaction(this, req)\n await migrationFile.down({ db, payload, req })\n payload.logger.info({\n msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this, db)\n\n if (tableExists) {\n await payload.delete({\n id: migration.id,\n collection: 'payload-migrations',\n overrideAccess: true,\n req,\n })\n }\n\n await commitTransaction(req)\n rolledBack.push(migrationFile.name)\n } catch (err: unknown) {\n await killTransaction(req)\n\n payload.logger.error({\n err,\n msg: parseError(err, `Error migrating down ${migrationFile.name}. Rolling back.`),\n })\n throw err\n }\n }\n\n return { batch: latestBatch, migrated: [], rolledBack }\n}\n"],"names":["commitTransaction","createPayloadRequest","getMigrations","initTransaction","killTransaction","readMigrationFiles","getTransaction","migrationTableExists","parseError","migrateDown","payload","migrationFiles","existingMigrations","latestBatch","length","logger","info","msg","migrated","rolledBack","latestBatchMigrations","filter","batch","migration","migrationFile","find","m","name","Error","start","Date","now","req","db","down","tableExists","delete","id","collection","overrideAccess","push","err","error"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,oBAAoB,EACpBC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,UAAS;AAIhB,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAMN,mBAAmB;QAAEK;IAAQ;IAE1D,MAAM,EAAEE,kBAAkB,EAAEC,WAAW,EAAE,GAAG,MAAMX,cAAc;QAC9DQ;IACF;IAEA,IAAI,CAACE,oBAAoBE,QAAQ;QAC/BJ,QAAQK,MAAM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ChBP;gBACF;YACF;YAEA,MAAMhC,kBAAkBgC;YACxBb,WAAWqB,IAAI,CAAChB,cAAcG,IAAI;QACpC,EAAE,OAAOc,KAAc;YACrB,MAAMrC,gBAAgB4B;YAEtBtB,QAAQK,MAAM,CAAC2B,KAAK,CAAC;gBACnBD;gBACAxB,KAAKT,WAAWiC,KAAK,CAAC,qBAAqB,EAAEjB,cAAcG,IAAI,CAAC,eAAe,CAAC;YAClF;YACA,MAAMc;QACR;IACF;IAEA,OAAO;QAAEnB,OAAOT;QAAaK,UAAU,EAAE;QAAEC;IAAW;AACxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateFresh.d.ts","sourceRoot":"","sources":["../src/migrateFresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAW9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,cAAc,EACpB,EAAE,kBAA0B,EAAE,YAAmB,EAAE;;;CAAA,GAClD,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"migrateFresh.d.ts","sourceRoot":"","sources":["../src/migrateFresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAW9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,cAAc,EACpB,EAAE,kBAA0B,EAAE,YAAmB,EAAE;;;CAAA,GAClD,OAAO,CAAC,eAAe,CAAC,CAsE1B"}
|
package/dist/migrateFresh.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { commitTransaction,
|
|
1
|
+
import { commitTransaction, createPayloadRequest, initTransaction, killTransaction, readMigrationFiles } from 'payload';
|
|
2
2
|
import prompts from 'prompts';
|
|
3
3
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
4
4
|
import { parseError } from './utilities/parseError.js';
|
|
@@ -40,7 +40,9 @@ import { parseError } from './utilities/parseError.js';
|
|
|
40
40
|
payload.logger.debug({
|
|
41
41
|
msg: `Found ${migrationFiles.length} migration files.`
|
|
42
42
|
});
|
|
43
|
-
const req = await
|
|
43
|
+
const req = await createPayloadRequest({
|
|
44
|
+
payload
|
|
45
|
+
});
|
|
44
46
|
const migrated = [];
|
|
45
47
|
if ('createExtensions' in this && typeof this.createExtensions === 'function') {
|
|
46
48
|
await this.createExtensions();
|
|
@@ -65,6 +67,7 @@ import { parseError } from './utilities/parseError.js';
|
|
|
65
67
|
name: migration.name,
|
|
66
68
|
batch: 1
|
|
67
69
|
},
|
|
70
|
+
overrideAccess: true,
|
|
68
71
|
req
|
|
69
72
|
});
|
|
70
73
|
await commitTransaction(req);
|
package/dist/migrateFresh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/migrateFresh.ts"],"sourcesContent":["import type { MigrationResult } from 'payload'\n\nimport {\n commitTransaction,\n
|
|
1
|
+
{"version":3,"sources":["../src/migrateFresh.ts"],"sourcesContent":["import type { MigrationResult } from 'payload'\n\nimport {\n commitTransaction,\n createPayloadRequest,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload'\nimport prompts from 'prompts'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { parseError } from './utilities/parseError.js'\n\n/**\n * Drop the current database and run all migrate up functions\n */\nexport async function migrateFresh(\n this: DrizzleAdapter,\n { forceAcceptWarning = false, shouldPrompt = true },\n): Promise<MigrationResult> {\n const { payload } = this\n\n if (forceAcceptWarning === false) {\n if (!shouldPrompt) {\n return { cancelled: true, migrated: [], rolledBack: [] }\n }\n\n const { confirm: acceptWarning } = await prompts({\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: `WARNING: This will drop your database and run all migrations. Are you sure you want to proceed?`,\n })\n\n if (!acceptWarning) {\n return { cancelled: true, migrated: [], rolledBack: [] }\n }\n }\n\n payload.logger.info({\n msg: `Dropping database.`,\n })\n\n await this.dropDatabase({ adapter: this })\n\n const migrationFiles = await readMigrationFiles({ payload })\n payload.logger.debug({\n msg: `Found ${migrationFiles.length} migration files.`,\n })\n\n const req = await createPayloadRequest({ payload })\n const migrated: string[] = []\n\n if ('createExtensions' in this && typeof this.createExtensions === 'function') {\n await this.createExtensions()\n }\n\n // Run all migrate up\n for (const migration of migrationFiles) {\n payload.logger.info({ msg: `Migrating: ${migration.name}` })\n try {\n const start = Date.now()\n await initTransaction(req)\n const db = await getTransaction(this, req)\n await migration.up({ db, payload, req })\n await payload.create({\n collection: 'payload-migrations',\n data: {\n name: migration.name,\n batch: 1,\n },\n overrideAccess: true,\n req,\n })\n await commitTransaction(req)\n migrated.push(migration.name)\n\n payload.logger.info({ msg: `Migrated: ${migration.name} (${Date.now() - start}ms)` })\n } catch (err: unknown) {\n await killTransaction(req)\n payload.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}. Rolling back`),\n })\n throw err\n }\n }\n\n return { batch: 1, migrated, rolledBack: [] }\n}\n"],"names":["commitTransaction","createPayloadRequest","initTransaction","killTransaction","readMigrationFiles","prompts","getTransaction","parseError","migrateFresh","forceAcceptWarning","shouldPrompt","payload","cancelled","migrated","rolledBack","confirm","acceptWarning","name","type","initial","message","logger","info","msg","dropDatabase","adapter","migrationFiles","debug","length","req","createExtensions","migration","start","Date","now","db","up","create","collection","data","batch","overrideAccess","push","err","error"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,UAAS;AAChB,OAAOC,aAAa,UAAS;AAI7B,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,UAAU,QAAQ,4BAA2B;AAEtD;;CAEC,GACD,OAAO,eAAeC,aAEpB,EAAEC,qBAAqB,KAAK,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E,CAAC;gBAAED;gBAAIxB;gBAASkB;YAAI;YACtC,MAAMlB,QAAQ0B,MAAM,CAAC;gBACnBC,YAAY;gBACZC,MAAM;oBACJtB,MAAMc,UAAUd,IAAI;oBACpBuB,OAAO;gBACT;gBACAC,gBAAgB;gBAChBZ;YACF;YACA,MAAM7B,kBAAkB6B;YACxBhB,SAAS6B,IAAI,CAACX,UAAUd,IAAI;YAE5BN,QAAQU,MAAM,CAACC,IAAI,CAAC;gBAAEC,KAAK,CAAC,WAAW,EAAEQ,UAAUd,IAAI,CAAC,EAAE,EAAEgB,KAAKC,GAAG,KAAKF,MAAM,GAAG,CAAC;YAAC;QACtF,EAAE,OAAOW,KAAc;YACrB,MAAMxC,gBAAgB0B;YACtBlB,QAAQU,MAAM,CAACuB,KAAK,CAAC;gBACnBD;gBACApB,KAAKhB,WAAWoC,KAAK,CAAC,wBAAwB,EAAEZ,UAAUd,IAAI,CAAC,cAAc,CAAC;YAChF;YACA,MAAM0B;QACR;IACF;IAEA,OAAO;QAAEH,OAAO;QAAG3B;QAAUC,YAAY,EAAE;IAAC;AAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateRefresh.d.ts","sourceRoot":"","sources":["../src/migrateRefresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAW9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"migrateRefresh.d.ts","sourceRoot":"","sources":["../src/migrateRefresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAW9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAgGnF"}
|
package/dist/migrateRefresh.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { commitTransaction,
|
|
1
|
+
import { commitTransaction, createPayloadRequest, getMigrations, initTransaction, killTransaction, readMigrationFiles } from 'payload';
|
|
2
2
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
3
3
|
import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
4
4
|
import { parseError } from './utilities/parseError.js';
|
|
@@ -24,7 +24,9 @@ import { parseError } from './utilities/parseError.js';
|
|
|
24
24
|
payload.logger.info({
|
|
25
25
|
msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`
|
|
26
26
|
});
|
|
27
|
-
const req = await
|
|
27
|
+
const req = await createPayloadRequest({
|
|
28
|
+
payload
|
|
29
|
+
});
|
|
28
30
|
const migrated = [];
|
|
29
31
|
const rolledBack = [];
|
|
30
32
|
// Reverse order of migrations to rollback
|
|
@@ -53,6 +55,7 @@ import { parseError } from './utilities/parseError.js';
|
|
|
53
55
|
if (tableExists) {
|
|
54
56
|
await payload.delete({
|
|
55
57
|
collection: 'payload-migrations',
|
|
58
|
+
overrideAccess: true,
|
|
56
59
|
req,
|
|
57
60
|
where: {
|
|
58
61
|
name: {
|
|
@@ -90,6 +93,7 @@ import { parseError } from './utilities/parseError.js';
|
|
|
90
93
|
name: migration.name,
|
|
91
94
|
executed: true
|
|
92
95
|
},
|
|
96
|
+
overrideAccess: true,
|
|
93
97
|
req
|
|
94
98
|
});
|
|
95
99
|
await commitTransaction(req);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/migrateRefresh.ts"],"sourcesContent":["import type { MigrationResult } from 'payload'\n\nimport {\n commitTransaction,\n
|
|
1
|
+
{"version":3,"sources":["../src/migrateRefresh.ts"],"sourcesContent":["import type { MigrationResult } from 'payload'\n\nimport {\n commitTransaction,\n createPayloadRequest,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\nimport { parseError } from './utilities/parseError.js'\n\n/**\n * Run all migration down functions before running up\n */\nexport async function migrateRefresh(this: DrizzleAdapter): Promise<MigrationResult> {\n const { payload } = this\n const migrationFiles = await readMigrationFiles({ payload })\n\n const { existingMigrations, latestBatch } = await getMigrations({\n payload,\n })\n\n if (!existingMigrations?.length) {\n payload.logger.info({ msg: 'No migrations to rollback.' })\n return { migrated: [], rolledBack: [] }\n }\n\n payload.logger.info({\n msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`,\n })\n\n const req = await createPayloadRequest({ payload })\n const migrated: string[] = []\n const rolledBack: string[] = []\n\n // Reverse order of migrations to rollback\n existingMigrations.reverse()\n\n for (const migration of existingMigrations) {\n try {\n const migrationFile = migrationFiles.find((m) => m.name === migration.name)\n if (!migrationFile) {\n throw new Error(`Migration ${migration.name} not found locally.`)\n }\n\n payload.logger.info({ msg: `Migrating down: ${migration.name}` })\n const start = Date.now()\n await initTransaction(req)\n const db = await getTransaction(this, req)\n await migrationFile.down({ db, payload, req })\n payload.logger.info({\n msg: `Migrated down: ${migration.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this, db)\n if (tableExists) {\n await payload.delete({\n collection: 'payload-migrations',\n overrideAccess: true,\n req,\n where: {\n name: {\n equals: migration.name,\n },\n },\n })\n }\n await commitTransaction(req)\n rolledBack.push(migration.name)\n } catch (err: unknown) {\n await killTransaction(req)\n payload.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}. Rolling back.`),\n })\n throw err\n }\n }\n\n // Run all migrate up\n for (const migration of migrationFiles) {\n payload.logger.info({ msg: `Migrating: ${migration.name}` })\n try {\n const start = Date.now()\n await initTransaction(req)\n await migration.up({ payload, req })\n await payload.create({\n collection: 'payload-migrations',\n data: {\n name: migration.name,\n executed: true,\n },\n overrideAccess: true,\n req,\n })\n await commitTransaction(req)\n migrated.push(migration.name)\n\n payload.logger.info({ msg: `Migrated: ${migration.name} (${Date.now() - start}ms)` })\n } catch (err: unknown) {\n await killTransaction(req)\n payload.logger.error({\n err,\n msg: parseError(err, `Error running migration ${migration.name}. Rolling back.`),\n })\n throw err\n }\n }\n\n return { migrated, rolledBack }\n}\n"],"names":["commitTransaction","createPayloadRequest","getMigrations","initTransaction","killTransaction","readMigrationFiles","getTransaction","migrationTableExists","parseError","migrateRefresh","payload","migrationFiles","existingMigrations","latestBatch","length","logger","info","msg","migrated","rolledBack","req","reverse","migration","migrationFile","find","m","name","Error","start","Date","now","db","down","tableExists","delete","collection","overrideAccess","where","equals","push","err","error","up","create","data","executed"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,oBAAoB,EACpBC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,UAAS;AAIhB,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,4BAA2B;AAEtD;;CAEC,GACD,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAMN,mBAAmB;QAAEK;IAAQ;IAE1D,MAAM,EAAEE,kBAAkB,EAAEC,WAAW,EAAE,GAAG,MAAMX,cAAc;QAC9DQ;IACF;IAEA,IAAI,CAACE,oBAAoBE,QAAQ;QAC/BJ,QAAQK,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAA6B;QACxD,OAAO;YAAEC,UAAU,EAAE;YAAEC,YAAY,EAAE;QAAC;IACxC;IAEAT,QAAQK,MAAM,CAACC,IAAI,CAAC;QAClBC,KAAK,CAAC,mBAAmB,EAAEJ,YAAY,eAAe,EAAED,mBAAmBE,MAAM,CAAC,cAAc,CAAC;IACnG;IAEA,MAAMM,MAA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O,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"migrateReset.d.ts","sourceRoot":"","sources":["../src/migrateReset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAW9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAkFjF"}
|
package/dist/migrateReset.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { commitTransaction,
|
|
1
|
+
import { commitTransaction, createPayloadRequest, getMigrations, initTransaction, killTransaction, readMigrationFiles } from 'payload';
|
|
2
2
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
3
3
|
import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
4
4
|
/**
|
|
@@ -20,7 +20,9 @@ import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
|
20
20
|
rolledBack: []
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
const req = await
|
|
23
|
+
const req = await createPayloadRequest({
|
|
24
|
+
payload
|
|
25
|
+
});
|
|
24
26
|
existingMigrations.reverse();
|
|
25
27
|
const rolledBack = [];
|
|
26
28
|
// Rollback all migrations in order
|
|
@@ -49,6 +51,7 @@ import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
|
49
51
|
await payload.delete({
|
|
50
52
|
id: migration.id,
|
|
51
53
|
collection: 'payload-migrations',
|
|
54
|
+
overrideAccess: true,
|
|
52
55
|
req
|
|
53
56
|
});
|
|
54
57
|
}
|
|
@@ -73,6 +76,7 @@ import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
|
73
76
|
try {
|
|
74
77
|
await payload.delete({
|
|
75
78
|
collection: 'payload-migrations',
|
|
79
|
+
overrideAccess: true,
|
|
76
80
|
where: {
|
|
77
81
|
batch: {
|
|
78
82
|
equals: -1
|
package/dist/migrateReset.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/migrateReset.ts"],"sourcesContent":["import type { MigrationResult } from 'payload'\n\nimport {\n commitTransaction,\n
|
|
1
|
+
{"version":3,"sources":["../src/migrateReset.ts"],"sourcesContent":["import type { MigrationResult } from 'payload'\n\nimport {\n commitTransaction,\n createPayloadRequest,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\n\n/**\n * Run all migrate down functions\n */\nexport async function migrateReset(this: DrizzleAdapter): Promise<MigrationResult> {\n const { payload } = this\n const migrationFiles = await readMigrationFiles({ payload })\n\n const { existingMigrations } = await getMigrations({ payload })\n\n if (!existingMigrations?.length) {\n payload.logger.info({ msg: 'No migrations to reset.' })\n return { migrated: [], rolledBack: [] }\n }\n\n const req = await createPayloadRequest({ payload })\n\n existingMigrations.reverse()\n const rolledBack: string[] = []\n\n // Rollback all migrations in order\n for (const migration of existingMigrations) {\n const migrationFile = migrationFiles.find((m) => m.name === migration.name)\n try {\n if (!migrationFile) {\n throw new Error(`Migration ${migration.name} not found locally.`)\n }\n\n const start = Date.now()\n payload.logger.info({ msg: `Migrating down: ${migrationFile.name}` })\n await initTransaction(req)\n const db = await getTransaction(this, req)\n await migrationFile.down({ db, payload, req })\n payload.logger.info({\n msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this, db)\n if (tableExists) {\n await payload.delete({\n id: migration.id,\n collection: 'payload-migrations',\n overrideAccess: true,\n req,\n })\n }\n\n await commitTransaction(req)\n rolledBack.push(migrationFile.name)\n } catch (err: unknown) {\n let msg = `Error running migration ${migrationFile.name}.`\n\n if (err instanceof Error) {\n msg += ` ${err.message}`\n }\n\n await killTransaction(req)\n payload.logger.error({\n err,\n msg,\n })\n throw err\n }\n }\n\n // Delete dev migration\n\n const tableExists = await migrationTableExists(this)\n if (tableExists) {\n try {\n await payload.delete({\n collection: 'payload-migrations',\n overrideAccess: true,\n where: {\n batch: {\n equals: -1,\n },\n },\n })\n } catch (err: unknown) {\n payload.logger.error({ err, msg: 'Error deleting dev migration' })\n throw err\n }\n }\n\n return { migrated: [], rolledBack }\n}\n"],"names":["commitTransaction","createPayloadRequest","getMigrations","initTransaction","killTransaction","readMigrationFiles","getTransaction","migrationTableExists","migrateReset","payload","migrationFiles","existingMigrations","length","logger","info","msg","migrated","rolledBack","req","reverse","migration","migrationFile","find","m","name","Error","start","Date","now","db","down","tableExists","delete","id","collection","overrideAccess","push","err","message","error","where","batch","equals"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,oBAAoB,EACpBC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,UAAS;AAIhB,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E;;CAEC,GACD,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAML,mBAAmB;QAAEI;IAAQ;IAE1D,MAAM,EAAEE,kBAAkB,EAAE,GAAG,MAAMT,cAAc;QAAEO;IAAQ;IAE7D,IAAI,CAACE,oBAAoBC,QAAQ;QAC/BH,QAAQI,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAA0B;QACrD,OAAO;YAAEC,UAAU,EAAE;YAAEC,YAAY,EAAE;QAAC;IACxC;IAEA,MAAMC,MAAM,MAAMjB,qBAAqB;QAAEQ;IAAQ;IAEjDE,mBAAmBQ,OAAO;IAC1B,MAAMF,aAAuB,EAAE;IAE/B,mCAAmC;IACnC,KAAK,MAAMG,aAAaT,mBAAoB;QAC1C,MAAMU,gBAAgBX,eAAeY,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ,UAAUI,IAAI;QAC1E,IA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BAChBK,OAAO;oBACLC,OAAO;wBACLC,QAAQ,CAAC;oBACX;gBACF;YACF;QACF,EAAE,OAAOL,KAAc;YACrB5B,QAAQI,MAAM,CAAC0B,KAAK,CAAC;gBAAEF;gBAAKtB,KAAK;YAA+B;YAChE,MAAMsB;QACR;IACF;IAEA,OAAO;QAAErB,UAAU,EAAE;QAAEC;IAAW;AACpC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APIError } from 'payload';
|
|
2
2
|
import { SAFE_STRING_REGEX } from '../../utilities/escapeSQLValue.js';
|
|
3
|
-
import {
|
|
3
|
+
import { parseJSONPathSegment } from '../../utilities/parseJSONPathSegment.js';
|
|
4
4
|
const operatorMap = {
|
|
5
5
|
contains: '~',
|
|
6
6
|
equals: '==',
|
|
@@ -12,7 +12,7 @@ const operatorMap = {
|
|
|
12
12
|
};
|
|
13
13
|
const sanitizeValue = (value, operator)=>{
|
|
14
14
|
if (value === null) {
|
|
15
|
-
return `
|
|
15
|
+
return `null`;
|
|
16
16
|
}
|
|
17
17
|
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
18
18
|
return `${value}`;
|
|
@@ -33,7 +33,7 @@ const sanitizeValue = (value, operator)=>{
|
|
|
33
33
|
export const createJSONQuery = ({ column, operator, pathSegments, value })=>{
|
|
34
34
|
const columnName = typeof column === 'object' ? column.name : column;
|
|
35
35
|
const jsonPaths = pathSegments.slice(1).map((key)=>{
|
|
36
|
-
return `${
|
|
36
|
+
return `${parseJSONPathSegment(key).value}[*]`;
|
|
37
37
|
}).join('.');
|
|
38
38
|
const fullPath = pathSegments.length === 1 ? '$[*]' : `$.${jsonPaths}`;
|
|
39
39
|
let sql = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/postgres/createJSONQuery/index.ts"],"sourcesContent":["import { APIError } from 'payload'\n\nimport type { CreateJSONQueryArgs } from '../../types.js'\n\nimport { SAFE_STRING_REGEX } from '../../utilities/escapeSQLValue.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/postgres/createJSONQuery/index.ts"],"sourcesContent":["import { APIError } from 'payload'\n\nimport type { CreateJSONQueryArgs } from '../../types.js'\n\nimport { SAFE_STRING_REGEX } from '../../utilities/escapeSQLValue.js'\nimport { parseJSONPathSegment } from '../../utilities/parseJSONPathSegment.js'\n\nconst operatorMap: Record<string, string> = {\n contains: '~',\n equals: '==',\n in: 'in',\n like: 'like_regex',\n not_equals: '!=',\n not_in: 'in',\n not_like: '!like_regex',\n}\n\nconst sanitizeValue = (value: unknown, operator?: string): string => {\n if (value === null) {\n return `null`\n }\n\n if (typeof value === 'number' || typeof value === 'boolean') {\n return `${value}`\n }\n\n if (typeof value !== 'string') {\n throw new Error('Invalid value type')\n }\n\n if (!SAFE_STRING_REGEX.test(value)) {\n throw new APIError(`${value} is not allowed as a JSON query value`, 400)\n }\n\n const escaped = value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n\n const prefix = ['like', 'not_like'].includes(operator ?? '') ? '(?i)' : ''\n\n return `\"${prefix}${escaped}\"`\n}\n\nexport const createJSONQuery = ({ column, operator, pathSegments, value }: CreateJSONQueryArgs) => {\n const columnName = typeof column === 'object' ? column.name : column\n const jsonPaths = pathSegments\n .slice(1)\n .map((key) => {\n return `${parseJSONPathSegment(key).value}[*]`\n })\n .join('.')\n\n const fullPath = pathSegments.length === 1 ? '$[*]' : `$.${jsonPaths}`\n\n let sql = ''\n\n if (['in', 'not_in'].includes(operator) && Array.isArray(value)) {\n sql = '('\n value.forEach((item, i) => {\n sql = `${sql}${createJSONQuery({ column, operator: operator === 'in' ? 'equals' : 'not_equals', pathSegments, value: item })}${i === value.length - 1 ? '' : ` ${operator === 'in' ? 'OR' : 'AND'} `}`\n })\n sql = `${sql})`\n } else if (operator === 'exists') {\n sql = `${value === false ? 'NOT ' : ''}jsonb_path_exists(${columnName}, '${fullPath}')`\n } else if (['not_like'].includes(operator)) {\n const mappedOperator = operatorMap[operator]\n\n sql = `NOT jsonb_path_exists(${columnName}, '${fullPath} ? (@ ${mappedOperator.substring(1)} ${sanitizeValue(value, operator)})')`\n } else {\n sql = `jsonb_path_exists(${columnName}, '${fullPath} ? (@ ${operatorMap[operator]} ${sanitizeValue(value, operator)})')`\n }\n\n return sql\n}\n"],"names":["APIError","SAFE_STRING_REGEX","parseJSONPathSegment","operatorMap","contains","equals","in","like","not_equals","not_in","not_like","sanitizeValue","value","operator","Error","test","escaped","replace","prefix","includes","createJSONQuery","column","pathSegments","columnName","name","jsonPaths","slice","map","key","join","fullPath","length","sql","Array","isArray","forEach","item","i","mappedOperator","substring"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,UAAS;AAIlC,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,oBAAoB,QAAQ,0CAAyC;AAE9E,MAAMC,cAAsC;IAC1CC,UAAU;IACVC,QAAQ;IACRC,IAAI;IACJC,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,UAAU;AACZ;AAEA,MAAMC,gBAAgB,CAACC,OAAgBC;IACrC,IAAID,UAAU,MAAM;QAClB,OAAO,CAAC,IAAI,CAAC;IACf;IAEA,IAAI,OAAOA,UAAU,YAAY,OAAOA,UAAU,WAAW;QAC3D,OAAO,GAAGA,OAAO;IACnB;IAEA,IAAI,OAAOA,UAAU,UAAU;QAC7B,MAAM,IAAIE,MAAM;IAClB;IAEA,IAAI,CAACb,kBAAkBc,IAAI,CAACH,QAAQ;QAClC,MAAM,IAAIZ,SAAS,GAAGY,MAAM,qCAAqC,CAAC,EAAE;IACtE;IAEA,MAAMI,UAAUJ,MAAMK,OAAO,CAAC,OAAO,QAAQA,OAAO,CAAC,MAAM;IAE3D,MAAMC,SAAS;QAAC;QAAQ;KAAW,CAACC,QAAQ,CAACN,YAAY,MAAM,SAAS;IAExE,OAAO,CAAC,CAAC,EAAEK,SAASF,QAAQ,CAAC,CAAC;AAChC;AAEA,OAAO,MAAMI,kBAAkB,CAAC,EAAEC,MAAM,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W,CAACU,SAAS,CAAC,CAAC,EAAEF,cAAcC,OAAOC,UAAU,GAAG,CAAC;IAC1H;IAEA,OAAOmB;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../src/postgres/insert.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC,eAAO,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../src/postgres/insert.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC,eAAO,MAAM,MAAM,EAAE,MA2BpB,CAAA"}
|
package/dist/postgres/insert.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export const insert = async function insert({ db, onConflictDoUpdate, tableName, values }) {
|
|
1
|
+
export const insert = async function insert({ db, onConflictDoNothing, onConflictDoUpdate, tableName, values }) {
|
|
2
2
|
const table = this.tables[tableName];
|
|
3
3
|
let result;
|
|
4
|
-
if (
|
|
4
|
+
if (onConflictDoNothing) {
|
|
5
|
+
result = await db.insert(table).values(values).onConflictDoNothing(onConflictDoNothing).returning();
|
|
6
|
+
} else if (onConflictDoUpdate) {
|
|
5
7
|
result = await db.insert(table).values(values).onConflictDoUpdate(onConflictDoUpdate).returning();
|
|
6
8
|
} else {
|
|
7
9
|
result = await db.insert(table).values(values).returning();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/postgres/insert.ts"],"sourcesContent":["import type { TransactionPg } from '../types.js'\nimport type { Insert } from './types.js'\n\nexport const insert: Insert = async function insert({\n db,\n onConflictDoUpdate,\n tableName,\n values,\n}): Promise<Record<string, unknown>[]> {\n const table = this.tables[tableName]\n let result\n\n if (onConflictDoUpdate) {\n result = await (db as TransactionPg)\n .insert(table)\n .values(values)\n .onConflictDoUpdate(onConflictDoUpdate)\n .returning()\n } else {\n result = await (db as TransactionPg).insert(table).values(values).returning()\n }\n\n return result\n}\n"],"names":["insert","db","onConflictDoUpdate","tableName","values","table","tables","result","returning"],"mappings":"AAGA,OAAO,MAAMA,SAAiB,eAAeA,OAAO,EAClDC,EAAE,EACFC,kBAAkB,EAClBC,SAAS,EACTC,MAAM,EACP;IACC,MAAMC,QAAQ,IAAI,CAACC,MAAM,CAACH,UAAU;IACpC,IAAII;IAEJ,
|
|
1
|
+
{"version":3,"sources":["../../src/postgres/insert.ts"],"sourcesContent":["import type { TransactionPg } from '../types.js'\nimport type { Insert } from './types.js'\n\nexport const insert: Insert = async function insert({\n db,\n onConflictDoNothing,\n onConflictDoUpdate,\n tableName,\n values,\n}): Promise<Record<string, unknown>[]> {\n const table = this.tables[tableName]\n let result\n\n if (onConflictDoNothing) {\n result = await (db as TransactionPg)\n .insert(table)\n .values(values)\n .onConflictDoNothing(onConflictDoNothing)\n .returning()\n } else if (onConflictDoUpdate) {\n result = await (db as TransactionPg)\n .insert(table)\n .values(values)\n .onConflictDoUpdate(onConflictDoUpdate)\n .returning()\n } else {\n result = await (db as TransactionPg).insert(table).values(values).returning()\n }\n\n return result\n}\n"],"names":["insert","db","onConflictDoNothing","onConflictDoUpdate","tableName","values","table","tables","result","returning"],"mappings":"AAGA,OAAO,MAAMA,SAAiB,eAAeA,OAAO,EAClDC,EAAE,EACFC,mBAAmB,EACnBC,kBAAkB,EAClBC,SAAS,EACTC,MAAM,EACP;IACC,MAAMC,QAAQ,IAAI,CAACC,MAAM,CAACH,UAAU;IACpC,IAAII;IAEJ,IAAIN,qBAAqB;QACvBM,SAAS,MAAM,AAACP,GACbD,MAAM,CAACM,OACPD,MAAM,CAACA,QACPH,mBAAmB,CAACA,qBACpBO,SAAS;IACd,OAAO,IAAIN,oBAAoB;QAC7BK,SAAS,MAAM,AAACP,GACbD,MAAM,CAACM,OACPD,MAAM,CAACA,QACPF,kBAAkB,CAACA,oBACnBM,SAAS;IACd,OAAO;QACLD,SAAS,MAAM,AAACP,GAAqBD,MAAM,CAACM,OAAOD,MAAM,CAACA,QAAQI,SAAS;IAC7E;IAEA,OAAOD;AACT,EAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Payload } from 'payload';
|
|
2
|
+
import type { SizesToVariantsDirection, SizesToVariantsIndexRename } from '../../../utilities/getSizesToVariantsRenames.js';
|
|
3
|
+
type ExistingPostgresIndex = {
|
|
4
|
+
columns: string[];
|
|
5
|
+
isPartial: boolean;
|
|
6
|
+
name: string;
|
|
7
|
+
unique: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Moves every upload collection's stored image sizes between the legacy `sizes_*` columns and
|
|
11
|
+
* `variants_*` (main and versions tables), renaming each column in place so no data is copied,
|
|
12
|
+
* then renames the indexes on those columns to what the current schema expects. Skips columns
|
|
13
|
+
* that are already renamed, so it's safe to re-run.
|
|
14
|
+
*/
|
|
15
|
+
export declare function migratePostgresSizesToVariants({ db, direction, payload, }: {
|
|
16
|
+
db: any;
|
|
17
|
+
direction?: SizesToVariantsDirection;
|
|
18
|
+
payload: Payload;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
export declare function reservePostgresLegacyIndexName({ existingIndexes, index, reservedRelationNames, }: {
|
|
21
|
+
existingIndexes: ExistingPostgresIndex[];
|
|
22
|
+
index: SizesToVariantsIndexRename;
|
|
23
|
+
reservedRelationNames: Set<string>;
|
|
24
|
+
}): string;
|
|
25
|
+
export declare function resolvePostgresIndexRename({ existingIndexes, index, tableName, }: {
|
|
26
|
+
existingIndexes: ExistingPostgresIndex[];
|
|
27
|
+
index: SizesToVariantsIndexRename;
|
|
28
|
+
tableName: string;
|
|
29
|
+
}): string | undefined;
|
|
30
|
+
export declare function getPostgresSchemaRelationNames({ db, schemaName, }: {
|
|
31
|
+
db: any;
|
|
32
|
+
schemaName: string;
|
|
33
|
+
}): Promise<Set<string>>;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/postgres/predefinedMigrations/sizes-to-variants/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAItC,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,iDAAiD,CAAA;AAUxD,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;CAChB,CAAA;AAED;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAAC,EACnD,EAAE,EACF,SAAgB,EAChB,OAAO,GACR,EAAE;IACD,EAAE,EAAE,GAAG,CAAA;IACP,SAAS,CAAC,EAAE,wBAAwB,CAAA;IACpC,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8EhB;AAED,wBAAgB,8BAA8B,CAAC,EAC7C,eAAe,EACf,KAAK,EACL,qBAAqB,GACtB,EAAE;IACD,eAAe,EAAE,qBAAqB,EAAE,CAAA;IACxC,KAAK,EAAE,0BAA0B,CAAA;IACjC,qBAAqB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CACnC,GAAG,MAAM,CAgCT;AAED,wBAAgB,0BAA0B,CAAC,EACzC,eAAe,EACf,KAAK,EACL,SAAS,GACV,EAAE;IACD,eAAe,EAAE,qBAAqB,EAAE,CAAA;IACxC,KAAK,EAAE,0BAA0B,CAAA;IACjC,SAAS,EAAE,MAAM,CAAA;CAClB,GAAG,MAAM,GAAG,SAAS,CA2CrB;AAoED,wBAAsB,8BAA8B,CAAC,EACnD,EAAE,EACF,UAAU,GACX,EAAE;IACD,EAAE,EAAE,GAAG,CAAA;IACP,UAAU,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CASvB"}
|