@payloadcms/drizzle 3.5.1-canary.d9bd64a → 3.6.0
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/exports/postgres.d.ts +1 -2
- package/dist/exports/postgres.d.ts.map +1 -1
- package/dist/exports/postgres.js +1 -2
- package/dist/exports/postgres.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/migrateDown.d.ts.map +1 -1
- package/dist/migrateDown.js +2 -0
- package/dist/migrateDown.js.map +1 -1
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js +1 -2
- package/dist/migrateFresh.js.map +1 -1
- package/dist/migrateRefresh.d.ts.map +1 -1
- package/dist/migrateRefresh.js +2 -0
- package/dist/migrateRefresh.js.map +1 -1
- package/dist/migrateReset.d.ts.map +1 -1
- package/dist/migrateReset.js +2 -0
- package/dist/migrateReset.js.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +20 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.js +169 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +149 -0
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
- package/dist/postgres/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
- package/dist/postgres/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/index.d.ts +23 -0
- package/dist/postgres/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/index.js +212 -0
- package/dist/postgres/predefinedMigrations/v2-v3/index.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/migrateRelationships.d.ts +20 -0
- package/dist/postgres/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/migrateRelationships.js +63 -0
- package/dist/postgres/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.d.ts +23 -0
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.js +60 -0
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/types.d.ts +9 -0
- package/dist/postgres/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/v2-v3/types.js +6 -0
- package/dist/postgres/predefinedMigrations/v2-v3/types.js.map +1 -0
- package/dist/postgres/requireDrizzleKit.d.ts.map +1 -1
- package/dist/postgres/requireDrizzleKit.js +9 -1
- package/dist/postgres/requireDrizzleKit.js.map +1 -1
- package/dist/postgres/types.d.ts +54 -0
- package/dist/postgres/types.d.ts.map +1 -1
- package/dist/postgres/types.js.map +1 -1
- package/dist/types.d.ts +5 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/buildCreateMigration.d.ts +10 -0
- package/dist/utilities/buildCreateMigration.d.ts.map +1 -0
- package/dist/utilities/buildCreateMigration.js +98 -0
- package/dist/utilities/buildCreateMigration.js.map +1 -0
- package/dist/utilities/getMigrationTemplate.d.ts +4 -0
- package/dist/utilities/getMigrationTemplate.d.ts.map +1 -0
- package/dist/utilities/getMigrationTemplate.js +13 -0
- package/dist/utilities/getMigrationTemplate.js.map +1 -0
- package/package.json +4 -4
|
@@ -2,14 +2,13 @@ export { countDistinct } from '../postgres/countDistinct.js';
|
|
|
2
2
|
export { createDatabase } from '../postgres/createDatabase.js';
|
|
3
3
|
export { createExtensions } from '../postgres/createExtensions.js';
|
|
4
4
|
export { createJSONQuery } from '../postgres/createJSONQuery/index.js';
|
|
5
|
-
export { createMigration } from '../postgres/createMigration.js';
|
|
6
5
|
export { defaultDrizzleSnapshot } from '../postgres/defaultSnapshot.js';
|
|
7
6
|
export { deleteWhere } from '../postgres/deleteWhere.js';
|
|
8
7
|
export { dropDatabase } from '../postgres/dropDatabase.js';
|
|
9
8
|
export { execute } from '../postgres/execute.js';
|
|
10
|
-
export { getMigrationTemplate } from '../postgres/getMigrationTemplate.js';
|
|
11
9
|
export { init } from '../postgres/init.js';
|
|
12
10
|
export { insert } from '../postgres/insert.js';
|
|
11
|
+
export { migratePostgresV2toV3 } from '../postgres/predefinedMigrations/v2-v3/index.js';
|
|
13
12
|
export { requireDrizzleKit } from '../postgres/requireDrizzleKit.js';
|
|
14
13
|
export * from '../postgres/types.js';
|
|
15
14
|
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/exports/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAA;AACtE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/exports/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAA;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,cAAc,sBAAsB,CAAA"}
|
package/dist/exports/postgres.js
CHANGED
|
@@ -2,14 +2,13 @@ export { countDistinct } from '../postgres/countDistinct.js';
|
|
|
2
2
|
export { createDatabase } from '../postgres/createDatabase.js';
|
|
3
3
|
export { createExtensions } from '../postgres/createExtensions.js';
|
|
4
4
|
export { createJSONQuery } from '../postgres/createJSONQuery/index.js';
|
|
5
|
-
export { createMigration } from '../postgres/createMigration.js';
|
|
6
5
|
export { defaultDrizzleSnapshot } from '../postgres/defaultSnapshot.js';
|
|
7
6
|
export { deleteWhere } from '../postgres/deleteWhere.js';
|
|
8
7
|
export { dropDatabase } from '../postgres/dropDatabase.js';
|
|
9
8
|
export { execute } from '../postgres/execute.js';
|
|
10
|
-
export { getMigrationTemplate } from '../postgres/getMigrationTemplate.js';
|
|
11
9
|
export { init } from '../postgres/init.js';
|
|
12
10
|
export { insert } from '../postgres/insert.js';
|
|
11
|
+
export { migratePostgresV2toV3 } from '../postgres/predefinedMigrations/v2-v3/index.js';
|
|
13
12
|
export { requireDrizzleKit } from '../postgres/requireDrizzleKit.js';
|
|
14
13
|
export * from '../postgres/types.js';
|
|
15
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/exports/postgres.ts"],"sourcesContent":["export { countDistinct } from '../postgres/countDistinct.js'\nexport { createDatabase } from '../postgres/createDatabase.js'\nexport { createExtensions } from '../postgres/createExtensions.js'\nexport { createJSONQuery } from '../postgres/createJSONQuery/index.js'\nexport {
|
|
1
|
+
{"version":3,"sources":["../../src/exports/postgres.ts"],"sourcesContent":["export { countDistinct } from '../postgres/countDistinct.js'\nexport { createDatabase } from '../postgres/createDatabase.js'\nexport { createExtensions } from '../postgres/createExtensions.js'\nexport { createJSONQuery } from '../postgres/createJSONQuery/index.js'\nexport { defaultDrizzleSnapshot } from '../postgres/defaultSnapshot.js'\nexport { deleteWhere } from '../postgres/deleteWhere.js'\nexport { dropDatabase } from '../postgres/dropDatabase.js'\nexport { execute } from '../postgres/execute.js'\nexport { init } from '../postgres/init.js'\nexport { insert } from '../postgres/insert.js'\nexport { migratePostgresV2toV3 } from '../postgres/predefinedMigrations/v2-v3/index.js'\nexport { requireDrizzleKit } from '../postgres/requireDrizzleKit.js'\nexport * from '../postgres/types.js'\n"],"names":["countDistinct","createDatabase","createExtensions","createJSONQuery","defaultDrizzleSnapshot","deleteWhere","dropDatabase","execute","init","insert","migratePostgresV2toV3","requireDrizzleKit"],"mappings":"AAAA,SAASA,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,gBAAgB,QAAQ,kCAAiC;AAClE,SAASC,eAAe,QAAQ,uCAAsC;AACtE,SAASC,sBAAsB,QAAQ,iCAAgC;AACvE,SAASC,WAAW,QAAQ,6BAA4B;AACxD,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,OAAO,QAAQ,yBAAwB;AAChD,SAASC,IAAI,QAAQ,sBAAqB;AAC1C,SAASC,MAAM,QAAQ,wBAAuB;AAC9C,SAASC,qBAAqB,QAAQ,kDAAiD;AACvF,SAASC,iBAAiB,QAAQ,mCAAkC;AACpE,cAAc,uBAAsB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export { updateGlobal } from './updateGlobal.js';
|
|
|
34
34
|
export { updateGlobalVersion } from './updateGlobalVersion.js';
|
|
35
35
|
export { updateVersion } from './updateVersion.js';
|
|
36
36
|
export { upsertRow } from './upsertRow/index.js';
|
|
37
|
+
export { buildCreateMigration } from './utilities/buildCreateMigration.js';
|
|
37
38
|
export { buildIndexName } from './utilities/buildIndexName.js';
|
|
38
39
|
export { executeSchemaHooks } from './utilities/executeSchemaHooks.js';
|
|
39
40
|
export { extendDrizzleTable } from './utilities/extendDrizzleTable.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cA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,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export { updateGlobal } from './updateGlobal.js';
|
|
|
33
33
|
export { updateGlobalVersion } from './updateGlobalVersion.js';
|
|
34
34
|
export { updateVersion } from './updateVersion.js';
|
|
35
35
|
export { upsertRow } from './upsertRow/index.js';
|
|
36
|
+
export { buildCreateMigration } from './utilities/buildCreateMigration.js';
|
|
36
37
|
export { buildIndexName } from './utilities/buildIndexName.js';
|
|
37
38
|
export { executeSchemaHooks } from './utilities/executeSchemaHooks.js';
|
|
38
39
|
export { extendDrizzleTable } from './utilities/extendDrizzleTable.js';
|
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 { chainMethods } from './find/chainMethods.js'\nexport { findGlobal } from './findGlobal.js'\nexport { findGlobalVersions } from './findGlobalVersions.js'\nexport { findMigrationDir } from './findMigrationDir.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 { operatorMap } from './queries/operatorMap.js'\nexport type { Operators } from './queries/operatorMap.js'\nexport { queryDrafts } from './queryDrafts.js'\nexport { beginTransaction } from './transactions/beginTransaction.js'\nexport { commitTransaction } from './transactions/commitTransaction.js'\nexport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nexport { updateOne } from './update.js'\nexport { updateGlobal } from './updateGlobal.js'\nexport { updateGlobalVersion } from './updateGlobalVersion.js'\nexport { updateVersion } from './updateVersion.js'\nexport { upsertRow } from './upsertRow/index.js'\nexport { buildIndexName } from './utilities/buildIndexName.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","deleteMany","deleteOne","deleteVersions","destroy","find","chainMethods","findGlobal","findGlobalVersions","findMigrationDir","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","operatorMap","queryDrafts","beginTransaction","commitTransaction","rollbackTransaction","updateOne","updateGlobal","updateGlobalVersion","updateVersion","upsertRow","buildIndexName","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,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,yBAAwB;AACrD,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,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,WAAW,QAAQ,2BAA0B;AAEtD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,SAAS,QAAQ,cAAa;AACvC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,gCAAgC,QAAQ,kDAAiD"}
|
|
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 { chainMethods } from './find/chainMethods.js'\nexport { findGlobal } from './findGlobal.js'\nexport { findGlobalVersions } from './findGlobalVersions.js'\nexport { findMigrationDir } from './findMigrationDir.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 { operatorMap } from './queries/operatorMap.js'\nexport type { Operators } from './queries/operatorMap.js'\nexport { queryDrafts } from './queryDrafts.js'\nexport { beginTransaction } from './transactions/beginTransaction.js'\nexport { commitTransaction } from './transactions/commitTransaction.js'\nexport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nexport { updateOne } from './update.js'\nexport { updateGlobal } from './updateGlobal.js'\nexport { updateGlobalVersion } from './updateGlobalVersion.js'\nexport { updateVersion } from './updateVersion.js'\nexport { upsertRow } from './upsertRow/index.js'\nexport { buildCreateMigration } from './utilities/buildCreateMigration.js'\nexport { buildIndexName } from './utilities/buildIndexName.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","deleteMany","deleteOne","deleteVersions","destroy","find","chainMethods","findGlobal","findGlobalVersions","findMigrationDir","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","operatorMap","queryDrafts","beginTransaction","commitTransaction","rollbackTransaction","updateOne","updateGlobal","updateGlobalVersion","updateVersion","upsertRow","buildCreateMigration","buildIndexName","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,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,yBAAwB;AACrD,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,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,WAAW,QAAQ,2BAA0B;AAEtD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,SAAS,QAAQ,cAAa;AACvC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,gCAAgC,QAAQ,kDAAiD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateDown.d.ts","sourceRoot":"","sources":["../src/migrateDown.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,wBAAsB,WAAW,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"migrateDown.d.ts","sourceRoot":"","sources":["../src/migrateDown.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,wBAAsB,WAAW,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAyDrE"}
|
package/dist/migrateDown.js
CHANGED
|
@@ -33,7 +33,9 @@ export async function migrateDown() {
|
|
|
33
33
|
msg: `Migrating down: ${migrationFile.name}`
|
|
34
34
|
});
|
|
35
35
|
await initTransaction(req);
|
|
36
|
+
const db = this.sessions[await req.transactionID]?.db || this.drizzle;
|
|
36
37
|
await migrationFile.down({
|
|
38
|
+
db,
|
|
37
39
|
payload,
|
|
38
40
|
req
|
|
39
41
|
});
|
package/dist/migrateDown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/migrateDown.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport {\n commitTransaction,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\nimport { parseError } from './utilities/parseError.js'\n\nexport async function migrateDown(this: DrizzleAdapter): Promise<void> {\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\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\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 = { payload } as PayloadRequest\n\n try {\n payload.logger.info({ msg: `Migrating down: ${migrationFile.name}` })\n await initTransaction(req)\n await migrationFile.down({ payload, req })\n payload.logger.info({\n msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this)\n if (tableExists) {\n await payload.delete({\n id: migration.id,\n collection: 'payload-migrations',\n req,\n })\n }\n\n await commitTransaction(req)\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 process.exit(1)\n }\n }\n}\n"],"names":["commitTransaction","getMigrations","initTransaction","killTransaction","readMigrationFiles","migrationTableExists","parseError","migrateDown","payload","migrationFiles","existingMigrations","latestBatch","length","logger","info","msg","latestBatchMigrations","filter","batch","migration","migrationFile","find","m","name","Error","start","Date","now","req","down","tableExists","delete","id","collection","err","error","process","exit"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,UAAS;AAIhB,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAML,mBAAmB;QAAEI;IAAQ;IAE1D,MAAM,EAAEE,kBAAkB,EAAEC,WAAW,EAAE,GAAG,MAAMV,cAAc;QAC9DO;IACF;IAEA,IAAI,CAACE,oBAAoBE,QAAQ;QAC/BJ,QAAQK,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAA6B;QACxD;IACF;IAEAP,QAAQK,MAAM,CAACC,IAAI,CAAC;QAClBC,KAAK,CAAC,mBAAmB,EAAEJ,YAAY,eAAe,EAAED,mBAAmBE,MAAM,CAAC,cAAc,CAAC;IACnG;IAEA,MAAMI,wBAAwBN,mBAAmBO,MAAM,CAAC,CAAC,EAAEC,KAAK,EAAE,GAAKA,UAAUP;IAEjF,KAAK,MAAMQ,aAAaH,sBAAuB;QAC7C,MAAMI,gBAAgBX,eAAeY,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ,UAAUI,IAAI;QAC1E,IAAI,CAACH,eAAe;YAClB,MAAM,IAAII,MAAM,CAAC,UAAU,EAAEL,UAAUI,IAAI,CAAC,mBAAmB,CAAC;QAClE;QAEA,MAAME,QAAQC,KAAKC,GAAG;QACtB,MAAMC,MAAM;YAAEpB;QAAQ;QAEtB,IAAI;YACFA,QAAQK,MAAM,CAACC,IAAI,CAAC;gBAAEC,KAAK,CAAC,gBAAgB,EAAEK,cAAcG,IAAI,EAAE;YAAC;YACnE,MAAMrB,gBAAgB0B;YACtB,
|
|
1
|
+
{"version":3,"sources":["../src/migrateDown.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport {\n commitTransaction,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\nimport { parseError } from './utilities/parseError.js'\n\nexport async function migrateDown(this: DrizzleAdapter): Promise<void> {\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\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\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 = { payload } as PayloadRequest\n\n try {\n payload.logger.info({ msg: `Migrating down: ${migrationFile.name}` })\n await initTransaction(req)\n const db = this.sessions[await req.transactionID]?.db || this.drizzle\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)\n if (tableExists) {\n await payload.delete({\n id: migration.id,\n collection: 'payload-migrations',\n req,\n })\n }\n\n await commitTransaction(req)\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 process.exit(1)\n }\n }\n}\n"],"names":["commitTransaction","getMigrations","initTransaction","killTransaction","readMigrationFiles","migrationTableExists","parseError","migrateDown","payload","migrationFiles","existingMigrations","latestBatch","length","logger","info","msg","latestBatchMigrations","filter","batch","migration","migrationFile","find","m","name","Error","start","Date","now","req","db","sessions","transactionID","drizzle","down","tableExists","delete","id","collection","err","error","process","exit"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,aAAa,EACbC,eAAe,EACfC,eAAe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CpB,QAAQK,MAAM,CAACC,IAAI,CAAC;gBAClBC,KAAK,CAAC,gBAAgB,EAAEK,cAAcG,IAAI,CAAC,EAAE,EAAEG,KAAKC,GAAG,KAAKF,MAAM,GAAG,CAAC;YACxE;YAEA,MAAMS,cAAc,MAAM7B,qBAAqB,IAAI;YACnD,IAAI6B,aAAa;gBACf,MAAM1B,QAAQ2B,MAAM,CAAC;oBACnBC,IAAIjB,UAAUiB,EAAE;oBAChBC,YAAY;oBACZT;gBACF;YACF;YAEA,MAAM5B,kBAAkB4B;QAC1B,EAAE,OAAOU,KAAc;YACrB,MAAMnC,gBAAgByB;YAEtBpB,QAAQK,MAAM,CAAC0B,KAAK,CAAC;gBACnBD;gBACAvB,KAAKT,WAAWgC,KAAK,CAAC,qBAAqB,EAAElB,cAAcG,IAAI,CAAC,eAAe,CAAC;YAClF;YACAiB,QAAQC,IAAI,CAAC;QACf;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateFresh.d.ts","sourceRoot":"","sources":["../src/migrateFresh.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAIhD;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,cAAc,EACpB,EAAE,kBAA0B,EAAE;;CAAA,GAC7B,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"migrateFresh.d.ts","sourceRoot":"","sources":["../src/migrateFresh.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAIhD;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,cAAc,EACpB,EAAE,kBAA0B,EAAE;;CAAA,GAC7B,OAAO,CAAC,IAAI,CAAC,CAoEf"}
|
package/dist/migrateFresh.js
CHANGED
|
@@ -46,8 +46,7 @@ import { parseError } from './utilities/parseError.js';
|
|
|
46
46
|
try {
|
|
47
47
|
const start = Date.now();
|
|
48
48
|
await initTransaction(req);
|
|
49
|
-
const
|
|
50
|
-
const db = adapter?.sessions[await req.transactionID]?.db || adapter.drizzle;
|
|
49
|
+
const db = this.sessions[await req.transactionID]?.db || this.drizzle;
|
|
51
50
|
await migration.up({
|
|
52
51
|
db,
|
|
53
52
|
payload,
|
package/dist/migrateFresh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/migrateFresh.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport { commitTransaction, initTransaction, killTransaction, readMigrationFiles } from 'payload'\nimport prompts from 'prompts'\n\nimport type { DrizzleAdapter } from './types.js'\n\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 },\n): Promise<void> {\n const { payload } = this\n\n if (forceAcceptWarning === false) {\n const { confirm: acceptWarning } = await prompts(\n {\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 onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!acceptWarning) {\n process.exit(0)\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 = { payload } as PayloadRequest\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
|
|
1
|
+
{"version":3,"sources":["../src/migrateFresh.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport { commitTransaction, initTransaction, killTransaction, readMigrationFiles } from 'payload'\nimport prompts from 'prompts'\n\nimport type { DrizzleAdapter } from './types.js'\n\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 },\n): Promise<void> {\n const { payload } = this\n\n if (forceAcceptWarning === false) {\n const { confirm: acceptWarning } = await prompts(\n {\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 onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!acceptWarning) {\n process.exit(0)\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 = { payload } as PayloadRequest\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 = this.sessions[await req.transactionID]?.db || this.drizzle\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 req,\n })\n await commitTransaction(req)\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 process.exit(1)\n }\n }\n}\n"],"names":["commitTransaction","initTransaction","killTransaction","readMigrationFiles","prompts","parseError","migrateFresh","forceAcceptWarning","payload","confirm","acceptWarning","name","type","initial","message","onCancel","process","exit","logger","info","msg","dropDatabase","adapter","migrationFiles","debug","length","req","createExtensions","migration","start","Date","now","db","sessions","transactionID","drizzle","up","create","collection","data","batch","err","error"],"mappings":"AAEA,SAASA,iBAAiB,EAAEC,eAAe,EAAEC,eAAe,EAAEC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AACG,OAAO;YACrE,MAAMP,UAAUQ,EAAE,CAAC;gBAAEJ;gBAAIxB;gBAASkB;YAAI;YACtC,MAAMlB,QAAQ6B,MAAM,CAAC;gBACnBC,YAAY;gBACZC,MAAM;oBACJ5B,MAAMiB,UAAUjB,IAAI;oBACpB6B,OAAO;gBACT;gBACAd;YACF;YACA,MAAM1B,kBAAkB0B;YAExBlB,QAAQU,MAAM,CAACC,IAAI,CAAC;gBAAEC,KAAK,CAAC,WAAW,EAAEQ,UAAUjB,IAAI,CAAC,EAAE,EAAEmB,KAAKC,GAAG,KAAKF,MAAM,GAAG,CAAC;YAAC;QACtF,EAAE,OAAOY,KAAc;YACrB,MAAMvC,gBAAgBwB;YACtBlB,QAAQU,MAAM,CAACwB,KAAK,CAAC;gBACnBD;gBACArB,KAAKf,WAAWoC,KAAK,CAAC,wBAAwB,EAAEb,UAAUjB,IAAI,CAAC,cAAc,CAAC;YAChF;YACAK,QAAQC,IAAI,CAAC;QACf;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateRefresh.d.ts","sourceRoot":"","sources":["../src/migrateRefresh.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"migrateRefresh.d.ts","sourceRoot":"","sources":["../src/migrateRefresh.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD;;GAEG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,iBAwFxD"}
|
package/dist/migrateRefresh.js
CHANGED
|
@@ -36,7 +36,9 @@ import { parseError } from './utilities/parseError.js';
|
|
|
36
36
|
});
|
|
37
37
|
const start = Date.now();
|
|
38
38
|
await initTransaction(req);
|
|
39
|
+
const db = this.sessions[await req.transactionID]?.db || this.drizzle;
|
|
39
40
|
await migrationFile.down({
|
|
41
|
+
db,
|
|
40
42
|
payload,
|
|
41
43
|
req
|
|
42
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/migrateRefresh.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport {\n commitTransaction,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload'\n\nimport type { DrizzleAdapter } from './types.js'\n\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) {\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\n }\n\n payload.logger.info({\n msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`,\n })\n\n const req = { payload } as PayloadRequest\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 await migrationFile.down({ payload, req })\n payload.logger.info({\n msg: `Migrated down: ${migration.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this)\n if (tableExists) {\n await payload.delete({\n collection: 'payload-migrations',\n req,\n where: {\n name: {\n equals: migration.name,\n },\n },\n })\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}. Rolling back.`),\n })\n process.exit(1)\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 req,\n })\n await commitTransaction(req)\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 process.exit(1)\n }\n }\n}\n"],"names":["commitTransaction","getMigrations","initTransaction","killTransaction","readMigrationFiles","migrationTableExists","parseError","migrateRefresh","payload","migrationFiles","existingMigrations","latestBatch","length","logger","info","msg","req","reverse","migration","migrationFile","find","m","name","Error","start","Date","now","down","tableExists","delete","collection","where","equals","err","error","process","exit","up","create","data","executed"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,UAAS;AAIhB,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,4BAA2B;AAEtD;;CAEC,GACD,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAML,mBAAmB;QAAEI;IAAQ;IAE1D,MAAM,EAAEE,kBAAkB,EAAEC,WAAW,EAAE,GAAG,MAAMV,cAAc;QAC9DO;IACF;IAEA,IAAI,CAACE,oBAAoBE,QAAQ;QAC/BJ,QAAQK,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAA6B;QACxD;IACF;IAEAP,QAAQK,MAAM,CAACC,IAAI,CAAC;QAClBC,KAAK,CAAC,mBAAmB,EAAEJ,YAAY,eAAe,EAAED,mBAAmBE,MAAM,CAAC,cAAc,CAAC;IACnG;IAEA,MAAMI,MAAM;QAAER;IAAQ;IAEtB,0CAA0C;IAC1CE,mBAAmBO,OAAO;IAE1B,KAAK,MAAMC,aAAaR,mBAAoB;QAC1C,IAAI;YACF,MAAMS,gBAAgBV,eAAeW,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ,UAAUI,IAAI;YAC1E,IAAI,CAACH,eAAe;gBAClB,MAAM,IAAII,MAAM,CAAC,UAAU,EAAEL,UAAUI,IAAI,CAAC,mBAAmB,CAAC;YAClE;YAEAd,QAAQK,MAAM,CAACC,IAAI,CAAC;gBAAEC,KAAK,CAAC,gBAAgB,EAAEG,UAAUI,IAAI,EAAE;YAAC;YAC/D,MAAME,QAAQC,KAAKC,GAAG;YACtB,MAAMxB,gBAAgBc;YACtB,
|
|
1
|
+
{"version":3,"sources":["../src/migrateRefresh.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport {\n commitTransaction,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload'\n\nimport type { DrizzleAdapter } from './types.js'\n\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) {\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\n }\n\n payload.logger.info({\n msg: `Rolling back batch ${latestBatch} consisting of ${existingMigrations.length} migration(s).`,\n })\n\n const req = { payload } as PayloadRequest\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 = this.sessions[await req.transactionID]?.db || this.drizzle\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)\n if (tableExists) {\n await payload.delete({\n collection: 'payload-migrations',\n req,\n where: {\n name: {\n equals: migration.name,\n },\n },\n })\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}. Rolling back.`),\n })\n process.exit(1)\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 req,\n })\n await commitTransaction(req)\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 process.exit(1)\n }\n }\n}\n"],"names":["commitTransaction","getMigrations","initTransaction","killTransaction","readMigrationFiles","migrationTableExists","parseError","migrateRefresh","payload","migrationFiles","existingMigrations","latestBatch","length","logger","info","msg","req","reverse","migration","migrationFile","find","m","name","Error","start","Date","now","db","sessions","transactionID","drizzle","down","tableExists","delete","collection","where","equals","err","error","process","exit","up","create","data","executed"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,UAAS;AAIhB,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,UAAU,QAAQ,4BAA2B;AAEtD;;CAEC,GACD,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAML,mBAAmB;QAAEI;IAAQ;IAE1D,MAAM,EAAEE,kBAAkB,EAAEC,WAAW,EAAE,GAAG,MAAMV,cAAc;QAC9DO;IACF;IAEA,IAAI,CAACE,oBAAoBE,QAAQ;QAC/BJ,QAAQK,MAAM,CAACC,IAAI,CAAC;YAAEC,KAA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
{"version":3,"file":"migrateReset.d.ts","sourceRoot":"","sources":["../src/migrateReset.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAIhD;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAyEtE"}
|
package/dist/migrateReset.js
CHANGED
|
@@ -31,7 +31,9 @@ import { migrationTableExists } from './utilities/migrationTableExists.js';
|
|
|
31
31
|
msg: `Migrating down: ${migrationFile.name}`
|
|
32
32
|
});
|
|
33
33
|
await initTransaction(req);
|
|
34
|
+
const db = this.sessions[await req.transactionID]?.db || this.drizzle;
|
|
34
35
|
await migrationFile.down({
|
|
36
|
+
db,
|
|
35
37
|
payload,
|
|
36
38
|
req
|
|
37
39
|
});
|
package/dist/migrateReset.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/migrateReset.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport {\n commitTransaction,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\n\n/**\n * Run all migrate down functions\n */\nexport async function migrateReset(this: DrizzleAdapter): Promise<void> {\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\n }\n\n const req = { payload } as PayloadRequest\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 await migrationFile.down({ payload, req })\n payload.logger.info({\n msg: `Migrated down: ${migrationFile.name} (${Date.now() - start}ms)`,\n })\n\n const tableExists = await migrationTableExists(this)\n if (tableExists) {\n await payload.delete({\n id: migration.id,\n collection: 'payload-migrations',\n req,\n })\n }\n\n await commitTransaction(req)\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 process.exit(1)\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 where: {\n batch: {\n equals: -1,\n },\n },\n })\n } catch (err: unknown) {\n payload.logger.error({ err, msg: 'Error deleting dev migration' })\n }\n }\n}\n"],"names":["commitTransaction","getMigrations","initTransaction","killTransaction","readMigrationFiles","migrationTableExists","migrateReset","payload","migrationFiles","existingMigrations","length","logger","info","msg","req","migration","migrationFile","find","m","name","Error","start","Date","now","down","tableExists","delete","id","collection","err","message","error","process","exit","where","batch","equals"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,UAAS;AAIhB,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E;;CAEC,GACD,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAMJ,mBAAmB;QAAEG;IAAQ;IAE1D,MAAM,EAAEE,kBAAkB,EAAE,GAAG,MAAMR,cAAc;QAAEM;IAAQ;IAE7D,IAAI,CAACE,oBAAoBC,QAAQ;QAC/BH,QAAQI,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAA0B;QACrD;IACF;IAEA,MAAMC,MAAM;QAAEP;IAAQ;IAEtB,mCAAmC;IACnC,KAAK,MAAMQ,aAAaN,mBAAoB;QAC1C,MAAMO,gBAAgBR,eAAeS,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ,UAAUI,IAAI;QAC1E,IAAI;YACF,IAAI,CAACH,eAAe;gBAClB,MAAM,IAAII,MAAM,CAAC,UAAU,EAAEL,UAAUI,IAAI,CAAC,mBAAmB,CAAC;YAClE;YAEA,MAAME,QAAQC,KAAKC,GAAG;YACtBhB,QAAQI,MAAM,CAACC,IAAI,CAAC;gBAAEC,KAAK,CAAC,gBAAgB,EAAEG,cAAcG,IAAI,EAAE;YAAC;YACnE,MAAMjB,gBAAgBY;YACtB,
|
|
1
|
+
{"version":3,"sources":["../src/migrateReset.ts"],"sourcesContent":["import type { PayloadRequest } from 'payload'\n\nimport {\n commitTransaction,\n getMigrations,\n initTransaction,\n killTransaction,\n readMigrationFiles,\n} from 'payload'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { migrationTableExists } from './utilities/migrationTableExists.js'\n\n/**\n * Run all migrate down functions\n */\nexport async function migrateReset(this: DrizzleAdapter): Promise<void> {\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\n }\n\n const req = { payload } as PayloadRequest\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 = this.sessions[await req.transactionID]?.db || this.drizzle\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)\n if (tableExists) {\n await payload.delete({\n id: migration.id,\n collection: 'payload-migrations',\n req,\n })\n }\n\n await commitTransaction(req)\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 process.exit(1)\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 where: {\n batch: {\n equals: -1,\n },\n },\n })\n } catch (err: unknown) {\n payload.logger.error({ err, msg: 'Error deleting dev migration' })\n }\n }\n}\n"],"names":["commitTransaction","getMigrations","initTransaction","killTransaction","readMigrationFiles","migrationTableExists","migrateReset","payload","migrationFiles","existingMigrations","length","logger","info","msg","req","migration","migrationFile","find","m","name","Error","start","Date","now","db","sessions","transactionID","drizzle","down","tableExists","delete","id","collection","err","message","error","process","exit","where","batch","equals"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,UAAS;AAIhB,SAASC,oBAAoB,QAAQ,sCAAqC;AAE1E;;CAEC,GACD,OAAO,eAAeC;IACpB,MAAM,EAAEC,OAAO,EAAE,GAAG,IAAI;IACxB,MAAMC,iBAAiB,MAAMJ,mBAAmB;QAAEG;IAAQ;IAE1D,MAAM,EAAEE,kBAAkB,EAAE,GAAG,MAAMR,cAAc;QAAEM;IAAQ;IAE7D,IAAI,CAACE,oBAAoBC,QAAQ;QAC/BH,QAAQI,MAAM,CAACC,IAAI,CAAC;YAAEC,KAAK;QAA0B;QACrD;IACF;IAEA,MAAMC,MAAM;QAAEP;IAAQ;IAEtB,mCAAmC;IACnC,KAAK,MAAMQ,aAAaN,mBAAoB;QAC1C,MAAMO,gBAAgBR,eAAeS,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKJ,UAAUI,IAAI;QAC1E,IAAI;YACF,IAAI,CAACH,eAAe;gBAClB,MAAM,IAAII,MAAM,CAAC,UAAU,EAAEL,UAAUI,IAAI,CAAC,mBAAmB,CAAC;YAClE;YAEA,MAAME,QAAQC,KAAKC,GAAG;YACtBhB,QAAQI,MAAM,CAACC,IAAI,CAAC;gBAAEC,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
|
|
|
1
|
+
import type { FlattenedField, Payload, PayloadRequest } from 'payload';
|
|
2
|
+
import type { TransactionPg } from '../../../../types.js';
|
|
3
|
+
import type { BasePostgresAdapter } from '../../../types.js';
|
|
4
|
+
import type { DocsToResave } from '../types.js';
|
|
5
|
+
type Args = {
|
|
6
|
+
adapter: BasePostgresAdapter;
|
|
7
|
+
collectionSlug?: string;
|
|
8
|
+
db: TransactionPg;
|
|
9
|
+
debug: boolean;
|
|
10
|
+
docsToResave: DocsToResave;
|
|
11
|
+
fields: FlattenedField[];
|
|
12
|
+
globalSlug?: string;
|
|
13
|
+
isVersions: boolean;
|
|
14
|
+
payload: Payload;
|
|
15
|
+
req: PayloadRequest;
|
|
16
|
+
tableName: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const fetchAndResave: ({ adapter, collectionSlug, db, debug, docsToResave, fields, globalSlug, isVersions, payload, req, tableName, }: Args) => Promise<void>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK/C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,mBAAmB,CAAA;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,EAAE,EAAE,aAAa,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,YAAY,EAAE,YAAY,CAAA;IAC1B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,cAAc,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,cAAc,mHAYxB,IAAI,kBAwMN,CAAA"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { upsertRow } from '../../../../upsertRow/index.js';
|
|
2
|
+
import { traverseFields } from './traverseFields.js';
|
|
3
|
+
export const fetchAndResave = async ({ adapter, collectionSlug, db, debug, docsToResave, fields, globalSlug, isVersions, payload, req, tableName })=>{
|
|
4
|
+
for (const [id, rows] of Object.entries(docsToResave)){
|
|
5
|
+
if (collectionSlug) {
|
|
6
|
+
const collectionConfig = payload.collections[collectionSlug].config;
|
|
7
|
+
if (collectionConfig) {
|
|
8
|
+
if (isVersions) {
|
|
9
|
+
const doc = await payload.findVersionByID({
|
|
10
|
+
id,
|
|
11
|
+
collection: collectionSlug,
|
|
12
|
+
depth: 0,
|
|
13
|
+
fallbackLocale: null,
|
|
14
|
+
locale: 'all',
|
|
15
|
+
req,
|
|
16
|
+
showHiddenFields: true
|
|
17
|
+
});
|
|
18
|
+
if (debug) {
|
|
19
|
+
payload.logger.info(`The collection "${collectionConfig.slug}" version with ID ${id} will be migrated`);
|
|
20
|
+
}
|
|
21
|
+
traverseFields({
|
|
22
|
+
doc,
|
|
23
|
+
fields,
|
|
24
|
+
path: '',
|
|
25
|
+
rows
|
|
26
|
+
});
|
|
27
|
+
try {
|
|
28
|
+
await upsertRow({
|
|
29
|
+
id: doc.id,
|
|
30
|
+
adapter,
|
|
31
|
+
data: doc,
|
|
32
|
+
db,
|
|
33
|
+
fields,
|
|
34
|
+
ignoreResult: true,
|
|
35
|
+
operation: 'update',
|
|
36
|
+
req,
|
|
37
|
+
tableName
|
|
38
|
+
});
|
|
39
|
+
} catch (err) {
|
|
40
|
+
payload.logger.error(`"${collectionConfig.slug}" version with ID ${doc.id} FAILED TO MIGRATE`);
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
if (debug) {
|
|
44
|
+
payload.logger.info(`"${collectionConfig.slug}" version with ID ${doc.id} migrated successfully!`);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
const doc = await payload.findByID({
|
|
48
|
+
id,
|
|
49
|
+
collection: collectionSlug,
|
|
50
|
+
depth: 0,
|
|
51
|
+
fallbackLocale: null,
|
|
52
|
+
locale: 'all',
|
|
53
|
+
req,
|
|
54
|
+
showHiddenFields: true
|
|
55
|
+
});
|
|
56
|
+
if (debug) {
|
|
57
|
+
payload.logger.info(`The collection "${collectionConfig.slug}" with ID ${doc.id} will be migrated`);
|
|
58
|
+
}
|
|
59
|
+
traverseFields({
|
|
60
|
+
doc,
|
|
61
|
+
fields,
|
|
62
|
+
path: '',
|
|
63
|
+
rows
|
|
64
|
+
});
|
|
65
|
+
try {
|
|
66
|
+
await upsertRow({
|
|
67
|
+
id: doc.id,
|
|
68
|
+
adapter,
|
|
69
|
+
data: doc,
|
|
70
|
+
db,
|
|
71
|
+
fields,
|
|
72
|
+
ignoreResult: true,
|
|
73
|
+
operation: 'update',
|
|
74
|
+
req,
|
|
75
|
+
tableName
|
|
76
|
+
});
|
|
77
|
+
} catch (err) {
|
|
78
|
+
payload.logger.error(`The collection "${collectionConfig.slug}" with ID ${doc.id} has FAILED TO MIGRATE`);
|
|
79
|
+
throw err;
|
|
80
|
+
}
|
|
81
|
+
if (debug) {
|
|
82
|
+
payload.logger.info(`The collection "${collectionConfig.slug}" with ID ${doc.id} has migrated successfully!`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (globalSlug) {
|
|
88
|
+
const globalConfig = payload.config.globals?.find((global)=>global.slug === globalSlug);
|
|
89
|
+
if (globalConfig) {
|
|
90
|
+
if (isVersions) {
|
|
91
|
+
const { docs } = await payload.findGlobalVersions({
|
|
92
|
+
slug: globalSlug,
|
|
93
|
+
depth: 0,
|
|
94
|
+
fallbackLocale: null,
|
|
95
|
+
limit: 0,
|
|
96
|
+
locale: 'all',
|
|
97
|
+
req,
|
|
98
|
+
showHiddenFields: true
|
|
99
|
+
});
|
|
100
|
+
if (debug) {
|
|
101
|
+
payload.logger.info(`${docs.length} global "${globalSlug}" versions will be migrated`);
|
|
102
|
+
}
|
|
103
|
+
for (const doc of docs){
|
|
104
|
+
traverseFields({
|
|
105
|
+
doc,
|
|
106
|
+
fields,
|
|
107
|
+
path: '',
|
|
108
|
+
rows
|
|
109
|
+
});
|
|
110
|
+
try {
|
|
111
|
+
await upsertRow({
|
|
112
|
+
id: doc.id,
|
|
113
|
+
adapter,
|
|
114
|
+
data: doc,
|
|
115
|
+
db,
|
|
116
|
+
fields,
|
|
117
|
+
ignoreResult: true,
|
|
118
|
+
operation: 'update',
|
|
119
|
+
req,
|
|
120
|
+
tableName
|
|
121
|
+
});
|
|
122
|
+
} catch (err) {
|
|
123
|
+
payload.logger.error(`"${globalSlug}" version with ID ${doc.id} FAILED TO MIGRATE`);
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
126
|
+
if (debug) {
|
|
127
|
+
payload.logger.info(`"${globalSlug}" version with ID ${doc.id} migrated successfully!`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
const doc = await payload.findGlobal({
|
|
132
|
+
slug: globalSlug,
|
|
133
|
+
depth: 0,
|
|
134
|
+
fallbackLocale: null,
|
|
135
|
+
locale: 'all',
|
|
136
|
+
req,
|
|
137
|
+
showHiddenFields: true
|
|
138
|
+
});
|
|
139
|
+
traverseFields({
|
|
140
|
+
doc,
|
|
141
|
+
fields,
|
|
142
|
+
path: '',
|
|
143
|
+
rows
|
|
144
|
+
});
|
|
145
|
+
try {
|
|
146
|
+
await upsertRow({
|
|
147
|
+
adapter,
|
|
148
|
+
data: doc,
|
|
149
|
+
db,
|
|
150
|
+
fields,
|
|
151
|
+
ignoreResult: true,
|
|
152
|
+
operation: 'update',
|
|
153
|
+
req,
|
|
154
|
+
tableName
|
|
155
|
+
});
|
|
156
|
+
} catch (err) {
|
|
157
|
+
payload.logger.error(`The global "${globalSlug}" has FAILED TO MIGRATE`);
|
|
158
|
+
throw err;
|
|
159
|
+
}
|
|
160
|
+
if (debug) {
|
|
161
|
+
payload.logger.info(`The global "${globalSlug}" has migrated successfully!`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/postgres/predefinedMigrations/v2-v3/fetchAndResave/index.ts"],"sourcesContent":["import type { FlattenedField, Payload, PayloadRequest } from 'payload'\n\nimport type { TransactionPg } from '../../../../types.js'\nimport type { BasePostgresAdapter } from '../../../types.js'\nimport type { DocsToResave } from '../types.js'\n\nimport { upsertRow } from '../../../../upsertRow/index.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: BasePostgresAdapter\n collectionSlug?: string\n db: TransactionPg\n debug: boolean\n docsToResave: DocsToResave\n fields: FlattenedField[]\n globalSlug?: string\n isVersions: boolean\n payload: Payload\n req: PayloadRequest\n tableName: string\n}\n\nexport const fetchAndResave = async ({\n adapter,\n collectionSlug,\n db,\n debug,\n docsToResave,\n fields,\n globalSlug,\n isVersions,\n payload,\n req,\n tableName,\n}: Args) => {\n for (const [id, rows] of Object.entries(docsToResave)) {\n if (collectionSlug) {\n const collectionConfig = payload.collections[collectionSlug].config\n\n if (collectionConfig) {\n if (isVersions) {\n const doc = await payload.findVersionByID({\n id,\n collection: collectionSlug,\n depth: 0,\n fallbackLocale: null,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n if (debug) {\n payload.logger.info(\n `The collection \"${collectionConfig.slug}\" version with ID ${id} will be migrated`,\n )\n }\n\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n id: doc.id,\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(\n `\"${collectionConfig.slug}\" version with ID ${doc.id} FAILED TO MIGRATE`,\n )\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(\n `\"${collectionConfig.slug}\" version with ID ${doc.id} migrated successfully!`,\n )\n }\n } else {\n const doc = await payload.findByID({\n id,\n collection: collectionSlug,\n depth: 0,\n fallbackLocale: null,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n if (debug) {\n payload.logger.info(\n `The collection \"${collectionConfig.slug}\" with ID ${doc.id} will be migrated`,\n )\n }\n\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n id: doc.id,\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(\n `The collection \"${collectionConfig.slug}\" with ID ${doc.id} has FAILED TO MIGRATE`,\n )\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(\n `The collection \"${collectionConfig.slug}\" with ID ${doc.id} has migrated successfully!`,\n )\n }\n }\n }\n }\n\n if (globalSlug) {\n const globalConfig = payload.config.globals?.find((global) => global.slug === globalSlug)\n\n if (globalConfig) {\n if (isVersions) {\n const { docs } = await payload.findGlobalVersions({\n slug: globalSlug,\n depth: 0,\n fallbackLocale: null,\n limit: 0,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n if (debug) {\n payload.logger.info(`${docs.length} global \"${globalSlug}\" versions will be migrated`)\n }\n\n for (const doc of docs) {\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n id: doc.id,\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(`\"${globalSlug}\" version with ID ${doc.id} FAILED TO MIGRATE`)\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(\n `\"${globalSlug}\" version with ID ${doc.id} migrated successfully!`,\n )\n }\n }\n } else {\n const doc = await payload.findGlobal({\n slug: globalSlug,\n depth: 0,\n fallbackLocale: null,\n locale: 'all',\n req,\n showHiddenFields: true,\n })\n\n traverseFields({\n doc,\n fields,\n path: '',\n rows,\n })\n\n try {\n await upsertRow({\n adapter,\n data: doc,\n db,\n fields,\n ignoreResult: true,\n operation: 'update',\n req,\n tableName,\n })\n } catch (err) {\n payload.logger.error(`The global \"${globalSlug}\" has FAILED TO MIGRATE`)\n\n throw err\n }\n\n if (debug) {\n payload.logger.info(`The global \"${globalSlug}\" has migrated successfully!`)\n }\n }\n }\n }\n }\n}\n"],"names":["upsertRow","traverseFields","fetchAndResave","adapter","collectionSlug","db","debug","docsToResave","fields","globalSlug","isVersions","payload","req","tableName","id","rows","Object","entries","collectionConfig","collections","config","doc","findVersionByID","collection","depth","fallbackLocale","locale","showHiddenFields","logger","info","slug","path","data","ignoreResult","operation","err","error","findByID","globalConfig","globals","find","global","docs","findGlobalVersions","limit","length","findGlobal"],"mappings":"AAMA,SAASA,SAAS,QAAQ,iCAAgC;AAC1D,SAASC,cAAc,QAAQ,sBAAqB;AAgBpD,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,OAAO,EACPC,cAAc,EACdC,EAAE,EACFC,KAAK,EACLC,YAAY,EACZC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,OAAO,EACPC,GAAG,EACHC,SAAS,EACJ;IACL,KAAK,MAAM,CAACC,IAAIC,KAAK,IAAIC,OAAOC,OAAO,CAACV,cAAe;QACrD,IAAIH,gBAAgB;YAClB,MAAMc,mBAAmBP,QAAQQ,WAAW,CAACf,eAAe,CAACgB,MAAM;YAEnE,IAAIF,kBAAkB;gBACpB,IAAIR,YAAY;oBACd,MAAMW,MAAM,MAAMV,QAAQW,eAAe,CAAC;wBACx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3B,WAAW,kBAAkB,EAAEY,IAAIP,EAAE,CAAC,kBAAkB,CAAC;4BAElF,MAAMqB;wBACR;wBAEA,IAAI7B,OAAO;4BACTK,QAAQiB,MAAM,CAACC,IAAI,CACjB,CAAC,CAAC,EAAEpB,WAAW,kBAAkB,EAAEY,IAAIP,EAAE,CAAC,uBAAuB,CAAC;wBAEtE;oBACF;gBACF,OAAO;oBACL,MAAMO,MAAM,MAAMV,QAAQmC,UAAU,CAAC;wBACnChB,MAAMrB;wBACNe,OAAO;wBACPC,gBAAgB;wBAChBC,QAAQ;wBACRd;wBACAe,kBAAkB;oBACpB;oBAEA1B,eAAe;wBACboB;wBACAb;wBACAuB,MAAM;wBACNhB;oBACF;oBAEA,IAAI;wBACF,MAAMf,UAAU;4BACdG;4BACA6B,MAAMX;4BACNhB;4BACAG;4BACAyB,cAAc;4BACdC,WAAW;4BACXtB;4BACAC;wBACF;oBACF,EAAE,OAAOsB,KAAK;wBACZxB,QAAQiB,MAAM,CAACQ,KAAK,CAAC,CAAC,YAAY,EAAE3B,WAAW,uBAAuB,CAAC;wBAEvE,MAAM0B;oBACR;oBAEA,IAAI7B,OAAO;wBACTK,QAAQiB,MAAM,CAACC,IAAI,CAAC,CAAC,YAAY,EAAEpB,WAAW,4BAA4B,CAAC;oBAC7E;gBACF;YACF;QACF;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FlattenedField } from 'payload';
|
|
2
|
+
type Args = {
|
|
3
|
+
doc: Record<string, unknown>;
|
|
4
|
+
fields: FlattenedField[];
|
|
5
|
+
locale?: string;
|
|
6
|
+
path: string;
|
|
7
|
+
rows: Record<string, unknown>[];
|
|
8
|
+
};
|
|
9
|
+
export declare const traverseFields: ({ doc, fields, locale, path, rows }: Args) => void;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=traverseFields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../../src/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CAChC,CAAA;AAED,eAAO,MAAM,cAAc,wCAAyC,IAAI,SAgKvE,CAAA"}
|