@payloadcms/drizzle 4.0.0-internal.078835b → 4.0.0-internal.0b9bec1

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.
Files changed (30) hide show
  1. package/dist/exports/postgres.d.ts +1 -0
  2. package/dist/exports/postgres.d.ts.map +1 -1
  3. package/dist/exports/postgres.js +1 -0
  4. package/dist/exports/postgres.js.map +1 -1
  5. package/dist/exports/sqlite.d.ts +1 -0
  6. package/dist/exports/sqlite.d.ts.map +1 -1
  7. package/dist/exports/sqlite.js +1 -0
  8. package/dist/exports/sqlite.js.map +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/postgres/predefinedMigrations/jobs-processing-lease/index.d.ts +12 -0
  14. package/dist/postgres/predefinedMigrations/jobs-processing-lease/index.d.ts.map +1 -0
  15. package/dist/postgres/predefinedMigrations/jobs-processing-lease/index.js +22 -0
  16. package/dist/postgres/predefinedMigrations/jobs-processing-lease/index.js.map +1 -0
  17. package/dist/sqlite/predefinedMigrations/jobs-processing-lease/index.d.ts +12 -0
  18. package/dist/sqlite/predefinedMigrations/jobs-processing-lease/index.d.ts.map +1 -0
  19. package/dist/sqlite/predefinedMigrations/jobs-processing-lease/index.js +22 -0
  20. package/dist/sqlite/predefinedMigrations/jobs-processing-lease/index.js.map +1 -0
  21. package/dist/updateJobs.d.ts.map +1 -1
  22. package/dist/updateJobs.js +37 -0
  23. package/dist/updateJobs.js.map +1 -1
  24. package/dist/utilities/jobsProcessingLeaseMigration.d.ts +6 -0
  25. package/dist/utilities/jobsProcessingLeaseMigration.d.ts.map +1 -0
  26. package/dist/utilities/jobsProcessingLeaseMigration.js +64 -0
  27. package/dist/utilities/jobsProcessingLeaseMigration.js.map +1 -0
  28. package/dist/utilities/jobsProcessingLeaseMigration.spec.js +186 -0
  29. package/dist/utilities/jobsProcessingLeaseMigration.spec.js.map +1 -0
  30. package/package.json +3 -3
@@ -9,6 +9,7 @@ export { dropDatabase } from '../postgres/dropDatabase.js';
9
9
  export { execute } from '../postgres/execute.js';
10
10
  export { init } from '../postgres/init.js';
11
11
  export { insert } from '../postgres/insert.js';
12
+ export { migratePostgresJobsProcessingLease } from '../postgres/predefinedMigrations/jobs-processing-lease/index.js';
12
13
  export { migratePostgresLocalizeStatus } from '../postgres/predefinedMigrations/localize-status/index.js';
13
14
  export { migratePostgresV2toV3 } from '../postgres/predefinedMigrations/v2-v3/index.js';
14
15
  export { requireDrizzleKit } from '../postgres/requireDrizzleKit.js';
@@ -1 +1 @@
1
- {"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/exports/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,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,6BAA6B,EAAE,MAAM,2DAA2D,CAAA;AACzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AACrE,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/exports/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,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,kCAAkC,EAAE,MAAM,iEAAiE,CAAA;AACpH,OAAO,EAAE,6BAA6B,EAAE,MAAM,2DAA2D,CAAA;AACzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,iDAAiD,CAAA;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AACrE,cAAc,sBAAsB,CAAA"}
@@ -9,6 +9,7 @@ export { dropDatabase } from '../postgres/dropDatabase.js';
9
9
  export { execute } from '../postgres/execute.js';
10
10
  export { init } from '../postgres/init.js';
11
11
  export { insert } from '../postgres/insert.js';
12
+ export { migratePostgresJobsProcessingLease } from '../postgres/predefinedMigrations/jobs-processing-lease/index.js';
12
13
  export { migratePostgresLocalizeStatus } from '../postgres/predefinedMigrations/localize-status/index.js';
13
14
  export { migratePostgresV2toV3 } from '../postgres/predefinedMigrations/v2-v3/index.js';
14
15
  export { requireDrizzleKit } from '../postgres/requireDrizzleKit.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/postgres.ts"],"sourcesContent":["export { columnToCodeConverter } from '../postgres/columnToCodeConverter.js'\nexport { 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 { migratePostgresLocalizeStatus } from '../postgres/predefinedMigrations/localize-status/index.js'\nexport { migratePostgresV2toV3 } from '../postgres/predefinedMigrations/v2-v3/index.js'\nexport { requireDrizzleKit } from '../postgres/requireDrizzleKit.js'\nexport { geometryColumn } from '../postgres/schema/geometryColumn.js'\nexport * from '../postgres/types.js'\n"],"names":["columnToCodeConverter","countDistinct","createDatabase","createExtensions","createJSONQuery","defaultDrizzleSnapshot","deleteWhere","dropDatabase","execute","init","insert","migratePostgresLocalizeStatus","migratePostgresV2toV3","requireDrizzleKit","geometryColumn"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,uCAAsC;AAC5E,SAASC,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,6BAA6B,QAAQ,4DAA2D;AACzG,SAASC,qBAAqB,QAAQ,kDAAiD;AACvF,SAASC,iBAAiB,QAAQ,mCAAkC;AACpE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,cAAc,uBAAsB"}
1
+ {"version":3,"sources":["../../src/exports/postgres.ts"],"sourcesContent":["export { columnToCodeConverter } from '../postgres/columnToCodeConverter.js'\nexport { 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 { migratePostgresJobsProcessingLease } from '../postgres/predefinedMigrations/jobs-processing-lease/index.js'\nexport { migratePostgresLocalizeStatus } from '../postgres/predefinedMigrations/localize-status/index.js'\nexport { migratePostgresV2toV3 } from '../postgres/predefinedMigrations/v2-v3/index.js'\nexport { requireDrizzleKit } from '../postgres/requireDrizzleKit.js'\nexport { geometryColumn } from '../postgres/schema/geometryColumn.js'\nexport * from '../postgres/types.js'\n"],"names":["columnToCodeConverter","countDistinct","createDatabase","createExtensions","createJSONQuery","defaultDrizzleSnapshot","deleteWhere","dropDatabase","execute","init","insert","migratePostgresJobsProcessingLease","migratePostgresLocalizeStatus","migratePostgresV2toV3","requireDrizzleKit","geometryColumn"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,uCAAsC;AAC5E,SAASC,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,kCAAkC,QAAQ,kEAAiE;AACpH,SAASC,6BAA6B,QAAQ,4DAA2D;AACzG,SAASC,qBAAqB,QAAQ,kDAAiD;AACvF,SAASC,iBAAiB,QAAQ,mCAAkC;AACpE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,cAAc,uBAAsB"}
@@ -8,6 +8,7 @@ export { dropDatabase } from '../sqlite/dropDatabase.js';
8
8
  export { execute } from '../sqlite/execute.js';
9
9
  export { init } from '../sqlite/init.js';
10
10
  export { insert } from '../sqlite/insert.js';
11
+ export { migrateSqliteJobsProcessingLease } from '../sqlite/predefinedMigrations/jobs-processing-lease/index.js';
11
12
  export { migrateSqliteLocalizeStatus } from '../sqlite/predefinedMigrations/localize-status/index.js';
12
13
  export { requireDrizzleKit } from '../sqlite/requireDrizzleKit.js';
13
14
  export * from '../sqlite/types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/exports/sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAA;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAA;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/exports/sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yDAAyD,CAAA;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,gCAAgC,EAAE,MAAM,+DAA+D,CAAA;AAChH,OAAO,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAA;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,cAAc,oBAAoB,CAAA"}
@@ -8,6 +8,7 @@ export { dropDatabase } from '../sqlite/dropDatabase.js';
8
8
  export { execute } from '../sqlite/execute.js';
9
9
  export { init } from '../sqlite/init.js';
10
10
  export { insert } from '../sqlite/insert.js';
11
+ export { migrateSqliteJobsProcessingLease } from '../sqlite/predefinedMigrations/jobs-processing-lease/index.js';
11
12
  export { migrateSqliteLocalizeStatus } from '../sqlite/predefinedMigrations/localize-status/index.js';
12
13
  export { requireDrizzleKit } from '../sqlite/requireDrizzleKit.js';
13
14
  export * from '../sqlite/types.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/sqlite.ts"],"sourcesContent":["export { columnToCodeConverter } from '../sqlite/columnToCodeConverter.js'\nexport { countDistinct } from '../sqlite/countDistinct.js'\nexport { convertPathToJSONTraversal } from '../sqlite/createJSONQuery/convertPathToJSONTraversal.js'\nexport { createJSONQuery } from '../sqlite/createJSONQuery/index.js'\nexport { defaultDrizzleSnapshot } from '../sqlite/defaultSnapshot.js'\nexport { deleteWhere } from '../sqlite/deleteWhere.js'\nexport { dropDatabase } from '../sqlite/dropDatabase.js'\nexport { execute } from '../sqlite/execute.js'\nexport { init } from '../sqlite/init.js'\nexport { insert } from '../sqlite/insert.js'\nexport { migrateSqliteLocalizeStatus } from '../sqlite/predefinedMigrations/localize-status/index.js'\nexport { requireDrizzleKit } from '../sqlite/requireDrizzleKit.js'\nexport * from '../sqlite/types.js'\n"],"names":["columnToCodeConverter","countDistinct","convertPathToJSONTraversal","createJSONQuery","defaultDrizzleSnapshot","deleteWhere","dropDatabase","execute","init","insert","migrateSqliteLocalizeStatus","requireDrizzleKit"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,qCAAoC;AAC1E,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,SAASC,0BAA0B,QAAQ,0DAAyD;AACpG,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,sBAAsB,QAAQ,+BAA8B;AACrE,SAASC,WAAW,QAAQ,2BAA0B;AACtD,SAASC,YAAY,QAAQ,4BAA2B;AACxD,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,IAAI,QAAQ,oBAAmB;AACxC,SAASC,MAAM,QAAQ,sBAAqB;AAC5C,SAASC,2BAA2B,QAAQ,0DAAyD;AACrG,SAASC,iBAAiB,QAAQ,iCAAgC;AAClE,cAAc,qBAAoB"}
1
+ {"version":3,"sources":["../../src/exports/sqlite.ts"],"sourcesContent":["export { columnToCodeConverter } from '../sqlite/columnToCodeConverter.js'\nexport { countDistinct } from '../sqlite/countDistinct.js'\nexport { convertPathToJSONTraversal } from '../sqlite/createJSONQuery/convertPathToJSONTraversal.js'\nexport { createJSONQuery } from '../sqlite/createJSONQuery/index.js'\nexport { defaultDrizzleSnapshot } from '../sqlite/defaultSnapshot.js'\nexport { deleteWhere } from '../sqlite/deleteWhere.js'\nexport { dropDatabase } from '../sqlite/dropDatabase.js'\nexport { execute } from '../sqlite/execute.js'\nexport { init } from '../sqlite/init.js'\nexport { insert } from '../sqlite/insert.js'\nexport { migrateSqliteJobsProcessingLease } from '../sqlite/predefinedMigrations/jobs-processing-lease/index.js'\nexport { migrateSqliteLocalizeStatus } from '../sqlite/predefinedMigrations/localize-status/index.js'\nexport { requireDrizzleKit } from '../sqlite/requireDrizzleKit.js'\nexport * from '../sqlite/types.js'\n"],"names":["columnToCodeConverter","countDistinct","convertPathToJSONTraversal","createJSONQuery","defaultDrizzleSnapshot","deleteWhere","dropDatabase","execute","init","insert","migrateSqliteJobsProcessingLease","migrateSqliteLocalizeStatus","requireDrizzleKit"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,qCAAoC;AAC1E,SAASC,aAAa,QAAQ,6BAA4B;AAC1D,SAASC,0BAA0B,QAAQ,0DAAyD;AACpG,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,sBAAsB,QAAQ,+BAA8B;AACrE,SAASC,WAAW,QAAQ,2BAA0B;AACtD,SAASC,YAAY,QAAQ,4BAA2B;AACxD,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,IAAI,QAAQ,oBAAmB;AACxC,SAASC,MAAM,QAAQ,sBAAqB;AAC5C,SAASC,gCAAgC,QAAQ,gEAA+D;AAChH,SAASC,2BAA2B,QAAQ,0DAAyD;AACrG,SAASC,iBAAiB,QAAQ,iCAAgC;AAClE,cAAc,qBAAoB"}
package/dist/index.d.ts CHANGED
@@ -48,6 +48,7 @@ export { createSchemaGenerator } from './utilities/createSchemaGenerator.js';
48
48
  export { executeSchemaHooks } from './utilities/executeSchemaHooks.js';
49
49
  export { extendDrizzleTable } from './utilities/extendDrizzleTable.js';
50
50
  export { hasLocalesTable } from './utilities/hasLocalesTable.js';
51
+ export { buildDynamicPredefinedJobsProcessingLeaseMigration } from './utilities/jobsProcessingLeaseMigration.js';
51
52
  export { pushDevSchema } from './utilities/pushDevSchema.js';
52
53
  export { validateExistingBlockIsIdentical } from './utilities/validateExistingBlockIsIdentical.js';
53
54
  /**
@@ -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,cAAc,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,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M,gBAAgB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EACL,2CAA2C,EAC3C,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,kDAAkD,EAAE,MAAM,6CAA6C,CAAA;AAChH,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAA;AAGlG;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,mCAA0B,CAAA"}
package/dist/index.js CHANGED
@@ -46,6 +46,7 @@ export { createSchemaGenerator } from './utilities/createSchemaGenerator.js';
46
46
  export { executeSchemaHooks } from './utilities/executeSchemaHooks.js';
47
47
  export { extendDrizzleTable } from './utilities/extendDrizzleTable.js';
48
48
  export { hasLocalesTable } from './utilities/hasLocalesTable.js';
49
+ export { buildDynamicPredefinedJobsProcessingLeaseMigration } from './utilities/jobsProcessingLeaseMigration.js';
49
50
  export { pushDevSchema } from './utilities/pushDevSchema.js';
50
51
  export { validateExistingBlockIsIdentical } from './utilities/validateExistingBlockIsIdentical.js';
51
52
  import { findMigrationDir as payloadFindMigrationDir } from 'payload';
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 { Operators } from './queries/operatorMap.js'\nexport { parseParams } from './queries/parseParams.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 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'\nimport { findMigrationDir as payloadFindMigrationDir } from 'payload'\n\n/**\n * @deprecated remove in 4.0\n * use\n * ```ts\n * import { findMigrationDir } from 'payload'\n * ```\n */\nexport const findMigrationDir = payloadFindMigrationDir\n"],"names":["count","countGlobalVersions","countVersions","create","createGlobal","createGlobalVersion","createTableName","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findDistinct","findGlobal","findGlobalVersions","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","buildQuery","operatorMap","parseParams","queryDrafts","buildDrizzleRelations","buildRawSchema","beginTransaction","commitTransaction","rollbackTransaction","updateGlobal","updateGlobalVersion","updateJobs","updateMany","updateOne","updateVersion","upsert","upsertRow","buildDynamicPredefinedBlocksToJsonMigration","createBlocksToJsonMigrator","getBlocksToJsonMigrator","buildCreateMigration","buildIndexName","createSchemaGenerator","executeSchemaHooks","extendDrizzleTable","hasLocalesTable","pushDevSchema","validateExistingBlockIsIdentical","findMigrationDir","payloadFindMigrationDir"],"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,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,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;AAwC3E,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,SAAS,QAAQ,uBAAsB;AAChD,SACEC,2CAA2C,EAC3CC,0BAA0B,EAC1BC,uBAAuB,QAClB,sCAAqC;AAC5C,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,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;AAClG,SAASC,oBAAoBC,uBAAuB,QAAQ,UAAS;AAErE;;;;;;CAMC,GACD,OAAO,MAAMD,mBAAmBC,wBAAuB"}
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 { Operators } from './queries/operatorMap.js'\nexport { parseParams } from './queries/parseParams.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 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 { buildDynamicPredefinedJobsProcessingLeaseMigration } from './utilities/jobsProcessingLeaseMigration.js'\nexport { pushDevSchema } from './utilities/pushDevSchema.js'\nexport { validateExistingBlockIsIdentical } from './utilities/validateExistingBlockIsIdentical.js'\nimport { findMigrationDir as payloadFindMigrationDir } from 'payload'\n\n/**\n * @deprecated remove in 4.0\n * use\n * ```ts\n * import { findMigrationDir } from 'payload'\n * ```\n */\nexport const findMigrationDir = payloadFindMigrationDir\n"],"names":["count","countGlobalVersions","countVersions","create","createGlobal","createGlobalVersion","createTableName","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","findDistinct","findGlobal","findGlobalVersions","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","buildQuery","operatorMap","parseParams","queryDrafts","buildDrizzleRelations","buildRawSchema","beginTransaction","commitTransaction","rollbackTransaction","updateGlobal","updateGlobalVersion","updateJobs","updateMany","updateOne","updateVersion","upsert","upsertRow","buildDynamicPredefinedBlocksToJsonMigration","createBlocksToJsonMigrator","getBlocksToJsonMigrator","buildCreateMigration","buildIndexName","createSchemaGenerator","executeSchemaHooks","extendDrizzleTable","hasLocalesTable","buildDynamicPredefinedJobsProcessingLeaseMigration","pushDevSchema","validateExistingBlockIsIdentical","findMigrationDir","payloadFindMigrationDir"],"mappings":"AAAA,SAASA,KAAK,QAAQ,aAAY;AAClC,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,MA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,MAAM,QAAQ,cAAa;AACpC,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SACEC,2CAA2C,EAC3CC,0BAA0B,EAC1BC,uBAAuB,QAClB,sCAAqC;AAC5C,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,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,kDAAkD,QAAQ,8CAA6C;AAChH,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,gCAAgC,QAAQ,kDAAiD;AAClG,SAASC,oBAAoBC,uBAAuB,QAAQ,UAAS;AAErE;;;;;;CAMC,GACD,OAAO,MAAMD,mBAAmBC,wBAAuB"}
@@ -0,0 +1,12 @@
1
+ type Args = {
2
+ db: any;
3
+ direction: 'down' | 'up';
4
+ newIndexName: string;
5
+ oldIndexName: string;
6
+ schemaName?: string;
7
+ sql: any;
8
+ tableName: string;
9
+ };
10
+ export declare function migratePostgresJobsProcessingLease({ db, direction, newIndexName, oldIndexName, schemaName, sql, tableName, }: Args): Promise<void>;
11
+ export {};
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/postgres/predefinedMigrations/jobs-processing-lease/index.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,GAAG;IACV,EAAE,EAAE,GAAG,CAAA;IACP,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,GAAG,CAAA;IACR,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAID,wBAAsB,kCAAkC,CAAC,EACvD,EAAE,EACF,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,UAAqB,EACrB,GAAG,EACH,SAAS,GACV,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCtB"}
@@ -0,0 +1,22 @@
1
+ const quoteIdentifier = (identifier)=>`"${identifier.replaceAll('"', '""')}"`;
2
+ export async function migratePostgresJobsProcessingLease({ db, direction, newIndexName, oldIndexName, schemaName = 'public', sql, tableName }) {
3
+ const qualifiedTableName = `${quoteIdentifier(schemaName)}.${quoteIdentifier(tableName)}`;
4
+ const run = (statement)=>db.execute(sql.raw(statement));
5
+ if (direction === 'up') {
6
+ await run(`ALTER TABLE ${qualifiedTableName} ADD COLUMN "processing_until" timestamp(3) with time zone`);
7
+ await run(`ALTER TABLE ${qualifiedTableName} ADD COLUMN "processing_token" varchar`);
8
+ await run(`UPDATE ${qualifiedTableName} SET "processing_until" = '1970-01-01 00:00:00+00' WHERE "processing" = true`);
9
+ await run(`DROP INDEX IF EXISTS ${quoteIdentifier(schemaName)}.${quoteIdentifier(oldIndexName)}`);
10
+ await run(`ALTER TABLE ${qualifiedTableName} DROP COLUMN "processing"`);
11
+ await run(`CREATE INDEX ${quoteIdentifier(newIndexName)} ON ${qualifiedTableName} USING btree ("processing_until")`);
12
+ return;
13
+ }
14
+ await run(`ALTER TABLE ${qualifiedTableName} ADD COLUMN "processing" boolean DEFAULT false`);
15
+ await run(`UPDATE ${qualifiedTableName} SET "processing" = true WHERE "processing_until" IS NOT NULL`);
16
+ await run(`DROP INDEX IF EXISTS ${quoteIdentifier(schemaName)}.${quoteIdentifier(newIndexName)}`);
17
+ await run(`ALTER TABLE ${qualifiedTableName} DROP COLUMN "processing_token"`);
18
+ await run(`ALTER TABLE ${qualifiedTableName} DROP COLUMN "processing_until"`);
19
+ await run(`CREATE INDEX ${quoteIdentifier(oldIndexName)} ON ${qualifiedTableName} USING btree ("processing")`);
20
+ }
21
+
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/postgres/predefinedMigrations/jobs-processing-lease/index.ts"],"sourcesContent":["type Args = {\n db: any\n direction: 'down' | 'up'\n newIndexName: string\n oldIndexName: string\n schemaName?: string\n sql: any\n tableName: string\n}\n\nconst quoteIdentifier = (identifier: string): string => `\"${identifier.replaceAll('\"', '\"\"')}\"`\n\nexport async function migratePostgresJobsProcessingLease({\n db,\n direction,\n newIndexName,\n oldIndexName,\n schemaName = 'public',\n sql,\n tableName,\n}: Args): Promise<void> {\n const qualifiedTableName = `${quoteIdentifier(schemaName)}.${quoteIdentifier(tableName)}`\n const run = (statement: string) => db.execute(sql.raw(statement))\n\n if (direction === 'up') {\n await run(\n `ALTER TABLE ${qualifiedTableName} ADD COLUMN \"processing_until\" timestamp(3) with time zone`,\n )\n await run(`ALTER TABLE ${qualifiedTableName} ADD COLUMN \"processing_token\" varchar`)\n await run(\n `UPDATE ${qualifiedTableName} SET \"processing_until\" = '1970-01-01 00:00:00+00' WHERE \"processing\" = true`,\n )\n await run(\n `DROP INDEX IF EXISTS ${quoteIdentifier(schemaName)}.${quoteIdentifier(oldIndexName)}`,\n )\n await run(`ALTER TABLE ${qualifiedTableName} DROP COLUMN \"processing\"`)\n await run(\n `CREATE INDEX ${quoteIdentifier(newIndexName)} ON ${qualifiedTableName} USING btree (\"processing_until\")`,\n )\n\n return\n }\n\n await run(`ALTER TABLE ${qualifiedTableName} ADD COLUMN \"processing\" boolean DEFAULT false`)\n await run(\n `UPDATE ${qualifiedTableName} SET \"processing\" = true WHERE \"processing_until\" IS NOT NULL`,\n )\n await run(`DROP INDEX IF EXISTS ${quoteIdentifier(schemaName)}.${quoteIdentifier(newIndexName)}`)\n await run(`ALTER TABLE ${qualifiedTableName} DROP COLUMN \"processing_token\"`)\n await run(`ALTER TABLE ${qualifiedTableName} DROP COLUMN \"processing_until\"`)\n await run(\n `CREATE INDEX ${quoteIdentifier(oldIndexName)} ON ${qualifiedTableName} USING btree (\"processing\")`,\n )\n}\n"],"names":["quoteIdentifier","identifier","replaceAll","migratePostgresJobsProcessingLease","db","direction","newIndexName","oldIndexName","schemaName","sql","tableName","qualifiedTableName","run","statement","execute","raw"],"mappings":"AAUA,MAAMA,kBAAkB,CAACC,aAA+B,CAAC,CAAC,EAAEA,WAAWC,UAAU,CAAC,KAAK,MAAM,CAAC,CAAC;AAE/F,OAAO,eAAeC,mCAAmC,EACvDC,EAAE,EACFC,SAAS,EACTC,YAAY,EACZC,YAAY,EACZC,aAAa,QAAQ,EACrBC,GAAG,EACHC,SAAS,EACJ;IACL,MAAMC,qBAAqB,GAAGX,gBAAgBQ,YAAY,CAAC,EAAER,gBAAgBU,YAAY;IACzF,MAAME,MAAM,CAACC,YAAsBT,GAAGU,OAAO,CAACL,IAAIM,GAAG,CAACF;IAEtD,IAAIR,cAAc,MAAM;QACtB,MAAMO,IACJ,CAAC,YAAY,EAAED,mBAAmB,0DAA0D,CAAC;QAE/F,MAAMC,IAAI,CAAC,YAAY,EAAED,mBAAmB,sCAAsC,CAAC;QACnF,MAAMC,IACJ,CAAC,OAAO,EAAED,mBAAmB,4EAA4E,CAAC;QAE5G,MAAMC,IACJ,CAAC,qBAAqB,EAAEZ,gBAAgBQ,YAAY,CAAC,EAAER,gBAAgBO,eAAe;QAExF,MAAMK,IAAI,CAAC,YAAY,EAAED,mBAAmB,yBAAyB,CAAC;QACtE,MAAMC,IACJ,CAAC,aAAa,EAAEZ,gBAAgBM,cAAc,IAAI,EAAEK,mBAAmB,iCAAiC,CAAC;QAG3G;IACF;IAEA,MAAMC,IAAI,CAAC,YAAY,EAAED,mBAAmB,8CAA8C,CAAC;IAC3F,MAAMC,IACJ,CAAC,OAAO,EAAED,mBAAmB,6DAA6D,CAAC;IAE7F,MAAMC,IAAI,CAAC,qBAAqB,EAAEZ,gBAAgBQ,YAAY,CAAC,EAAER,gBAAgBM,eAAe;IAChG,MAAMM,IAAI,CAAC,YAAY,EAAED,mBAAmB,+BAA+B,CAAC;IAC5E,MAAMC,IAAI,CAAC,YAAY,EAAED,mBAAmB,+BAA+B,CAAC;IAC5E,MAAMC,IACJ,CAAC,aAAa,EAAEZ,gBAAgBO,cAAc,IAAI,EAAEI,mBAAmB,2BAA2B,CAAC;AAEvG"}
@@ -0,0 +1,12 @@
1
+ type Args = {
2
+ db: any;
3
+ direction: 'down' | 'up';
4
+ newIndexName: string;
5
+ oldIndexName: string;
6
+ schemaName?: string;
7
+ sql: any;
8
+ tableName: string;
9
+ };
10
+ export declare function migrateSqliteJobsProcessingLease({ db, direction, newIndexName, oldIndexName, sql, tableName, }: Args): Promise<void>;
11
+ export {};
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/sqlite/predefinedMigrations/jobs-processing-lease/index.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,GAAG;IACV,EAAE,EAAE,GAAG,CAAA;IACP,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,GAAG,CAAA;IACR,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAID,wBAAsB,gCAAgC,CAAC,EACrD,EAAE,EACF,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,GAAG,EACH,SAAS,GACV,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BtB"}
@@ -0,0 +1,22 @@
1
+ const quoteIdentifier = (identifier)=>`"${identifier.replaceAll('"', '""')}"`;
2
+ export async function migrateSqliteJobsProcessingLease({ db, direction, newIndexName, oldIndexName, sql, tableName }) {
3
+ const quotedTableName = quoteIdentifier(tableName);
4
+ const run = (statement)=>db.run(sql.raw(statement));
5
+ if (direction === 'up') {
6
+ await run(`ALTER TABLE ${quotedTableName} ADD COLUMN "processing_until" text`);
7
+ await run(`ALTER TABLE ${quotedTableName} ADD COLUMN "processing_token" text`);
8
+ await run(`UPDATE ${quotedTableName} SET "processing_until" = '1970-01-01T00:00:00.000Z' WHERE "processing" = true`);
9
+ await run(`DROP INDEX IF EXISTS ${quoteIdentifier(oldIndexName)}`);
10
+ await run(`ALTER TABLE ${quotedTableName} DROP COLUMN "processing"`);
11
+ await run(`CREATE INDEX ${quoteIdentifier(newIndexName)} ON ${quotedTableName} ("processing_until")`);
12
+ return;
13
+ }
14
+ await run(`ALTER TABLE ${quotedTableName} ADD COLUMN "processing" integer DEFAULT false`);
15
+ await run(`UPDATE ${quotedTableName} SET "processing" = true WHERE "processing_until" IS NOT NULL`);
16
+ await run(`DROP INDEX IF EXISTS ${quoteIdentifier(newIndexName)}`);
17
+ await run(`ALTER TABLE ${quotedTableName} DROP COLUMN "processing_token"`);
18
+ await run(`ALTER TABLE ${quotedTableName} DROP COLUMN "processing_until"`);
19
+ await run(`CREATE INDEX ${quoteIdentifier(oldIndexName)} ON ${quotedTableName} ("processing")`);
20
+ }
21
+
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/sqlite/predefinedMigrations/jobs-processing-lease/index.ts"],"sourcesContent":["type Args = {\n db: any\n direction: 'down' | 'up'\n newIndexName: string\n oldIndexName: string\n schemaName?: string\n sql: any\n tableName: string\n}\n\nconst quoteIdentifier = (identifier: string): string => `\"${identifier.replaceAll('\"', '\"\"')}\"`\n\nexport async function migrateSqliteJobsProcessingLease({\n db,\n direction,\n newIndexName,\n oldIndexName,\n sql,\n tableName,\n}: Args): Promise<void> {\n const quotedTableName = quoteIdentifier(tableName)\n const run = (statement: string) => db.run(sql.raw(statement))\n\n if (direction === 'up') {\n await run(`ALTER TABLE ${quotedTableName} ADD COLUMN \"processing_until\" text`)\n await run(`ALTER TABLE ${quotedTableName} ADD COLUMN \"processing_token\" text`)\n await run(\n `UPDATE ${quotedTableName} SET \"processing_until\" = '1970-01-01T00:00:00.000Z' WHERE \"processing\" = true`,\n )\n await run(`DROP INDEX IF EXISTS ${quoteIdentifier(oldIndexName)}`)\n await run(`ALTER TABLE ${quotedTableName} DROP COLUMN \"processing\"`)\n await run(\n `CREATE INDEX ${quoteIdentifier(newIndexName)} ON ${quotedTableName} (\"processing_until\")`,\n )\n\n return\n }\n\n await run(`ALTER TABLE ${quotedTableName} ADD COLUMN \"processing\" integer DEFAULT false`)\n await run(\n `UPDATE ${quotedTableName} SET \"processing\" = true WHERE \"processing_until\" IS NOT NULL`,\n )\n await run(`DROP INDEX IF EXISTS ${quoteIdentifier(newIndexName)}`)\n await run(`ALTER TABLE ${quotedTableName} DROP COLUMN \"processing_token\"`)\n await run(`ALTER TABLE ${quotedTableName} DROP COLUMN \"processing_until\"`)\n await run(`CREATE INDEX ${quoteIdentifier(oldIndexName)} ON ${quotedTableName} (\"processing\")`)\n}\n"],"names":["quoteIdentifier","identifier","replaceAll","migrateSqliteJobsProcessingLease","db","direction","newIndexName","oldIndexName","sql","tableName","quotedTableName","run","statement","raw"],"mappings":"AAUA,MAAMA,kBAAkB,CAACC,aAA+B,CAAC,CAAC,EAAEA,WAAWC,UAAU,CAAC,KAAK,MAAM,CAAC,CAAC;AAE/F,OAAO,eAAeC,iCAAiC,EACrDC,EAAE,EACFC,SAAS,EACTC,YAAY,EACZC,YAAY,EACZC,GAAG,EACHC,SAAS,EACJ;IACL,MAAMC,kBAAkBV,gBAAgBS;IACxC,MAAME,MAAM,CAACC,YAAsBR,GAAGO,GAAG,CAACH,IAAIK,GAAG,CAACD;IAElD,IAAIP,cAAc,MAAM;QACtB,MAAMM,IAAI,CAAC,YAAY,EAAED,gBAAgB,mCAAmC,CAAC;QAC7E,MAAMC,IAAI,CAAC,YAAY,EAAED,gBAAgB,mCAAmC,CAAC;QAC7E,MAAMC,IACJ,CAAC,OAAO,EAAED,gBAAgB,8EAA8E,CAAC;QAE3G,MAAMC,IAAI,CAAC,qBAAqB,EAAEX,gBAAgBO,eAAe;QACjE,MAAMI,IAAI,CAAC,YAAY,EAAED,gBAAgB,yBAAyB,CAAC;QACnE,MAAMC,IACJ,CAAC,aAAa,EAAEX,gBAAgBM,cAAc,IAAI,EAAEI,gBAAgB,qBAAqB,CAAC;QAG5F;IACF;IAEA,MAAMC,IAAI,CAAC,YAAY,EAAED,gBAAgB,8CAA8C,CAAC;IACxF,MAAMC,IACJ,CAAC,OAAO,EAAED,gBAAgB,6DAA6D,CAAC;IAE1F,MAAMC,IAAI,CAAC,qBAAqB,EAAEX,gBAAgBM,eAAe;IACjE,MAAMK,IAAI,CAAC,YAAY,EAAED,gBAAgB,+BAA+B,CAAC;IACzE,MAAMC,IAAI,CAAC,YAAY,EAAED,gBAAgB,+BAA+B,CAAC;IACzE,MAAMC,IAAI,CAAC,aAAa,EAAEX,gBAAgBO,cAAc,IAAI,EAAEG,gBAAgB,eAAe,CAAC;AAChG"}
@@ -1 +1 @@
1
- {"version":3,"file":"updateJobs.d.ts","sourceRoot":"","sources":["../src/updateJobs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAS,MAAM,SAAS,CAAA;AAYhD,eAAO,MAAM,UAAU,EAAE,UA2FxB,CAAA"}
1
+ {"version":3,"file":"updateJobs.d.ts","sourceRoot":"","sources":["../src/updateJobs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAS,MAAM,SAAS,CAAA;AAsBhD,eAAO,MAAM,UAAU,EAAE,UAsIxB,CAAA"}
@@ -1,9 +1,13 @@
1
+ import { and, inArray, isNull, lte, or } from 'drizzle-orm';
1
2
  import toSnakeCase from 'to-snake-case';
2
3
  import { findMany } from './find/findMany.js';
4
+ import { transformForWrite } from './transform/write/index.js';
3
5
  import { upsertRow } from './upsertRow/index.js';
4
6
  import { shouldUseOptimizedUpsertRow } from './upsertRow/shouldUseOptimizedUpsertRow.js';
5
7
  import { getPrimaryDb } from './utilities/getPrimaryDb.js';
6
8
  import { getTransaction } from './utilities/getTransaction.js';
9
+ import { markWrite } from './utilities/readAfterWrite.js';
10
+ const isInitialJobClaim = (data)=>typeof data.processingToken === 'string' && typeof data.processingUntil === 'string' && Object.keys(data).every((field)=>field === 'processingToken' || field === 'processingUntil' || field === 'updatedAt');
7
11
  export const updateJobs = async function updateMany({ id, data, limit: limitArg, req, returning, sort: sortArg, where: whereArg }) {
8
12
  if (!data?.log?.length && !(data.log && typeof data.log === 'object' && '$push' in data.log)) {
9
13
  delete data.log;
@@ -54,6 +58,39 @@ export const updateJobs = async function updateMany({ id, data, limit: limitArg,
54
58
  return [];
55
59
  }
56
60
  const db = getPrimaryDb(this, await getTransaction(this, req));
61
+ if (isInitialJobClaim(data)) {
62
+ // Atomically claim jobs so multiple workers cannot pick up the same job.
63
+ // We don't need FOR UPDATE SKIP LOCKED here because of the compare-and-swap-style update using processingUntil and processingToken.
64
+ // The first update makes the where clause fail for other workers, so they cannot claim the same job.
65
+ const _db = db;
66
+ const table = this.tables[tableName];
67
+ const now = new Date().toISOString();
68
+ const { row } = transformForWrite({
69
+ adapter: this,
70
+ data,
71
+ enableAtomicWrites: true,
72
+ fields: collection.flattenedFields,
73
+ tableName
74
+ });
75
+ if (typeof row.updatedAt === 'undefined' || row.updatedAt === null) {
76
+ delete row.updatedAt;
77
+ }
78
+ const jobIDs = jobs.docs.map((job)=>job.id);
79
+ const claimedRows = await _db.update(table).set(row).where(and(inArray(table.id, jobIDs), or(isNull(table.processingUntil), lte(table.processingUntil, now)))).returning({
80
+ id: table.id
81
+ });
82
+ if (claimedRows.length) {
83
+ markWrite(this);
84
+ }
85
+ if (returning === false) {
86
+ return null;
87
+ }
88
+ const claimedIDs = new Set(claimedRows.map(({ id })=>id));
89
+ return jobs.docs.filter((job)=>claimedIDs.has(job.id)).map((job)=>({
90
+ ...job,
91
+ ...data
92
+ }));
93
+ }
57
94
  const results = [];
58
95
  // TODO: We need to batch this to reduce the amount of db calls. This can get very slow if we are updating a lot of rows.
59
96
  for (const job of jobs.docs){
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateJobs.ts"],"sourcesContent":["import type { UpdateJobs, Where } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { shouldUseOptimizedUpsertRow } from './upsertRow/shouldUseOptimizedUpsertRow.js'\nimport { getPrimaryDb } from './utilities/getPrimaryDb.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const updateJobs: UpdateJobs = async function updateMany(\n this: DrizzleAdapter,\n { id, data, limit: limitArg, req, returning, sort: sortArg, where: whereArg },\n) {\n if (\n !(data?.log as object[])?.length &&\n !(data.log && typeof data.log === 'object' && '$push' in data.log)\n ) {\n delete data.log\n }\n\n const whereToUse: Where = id ? { id: { equals: id } } : whereArg\n const limit = id ? 1 : limitArg\n\n const collection = this.payload.collections['payload-jobs'].config\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n const sort = sortArg !== undefined && sortArg !== null ? sortArg : collection.defaultSort\n\n const useOptimizedUpsertRow = shouldUseOptimizedUpsertRow({\n data,\n fields: collection.flattenedFields,\n })\n\n if (useOptimizedUpsertRow && id) {\n const db = getPrimaryDb(this, await getTransaction(this, req))\n\n const result = await upsertRow({\n id,\n adapter: this,\n collectionSlug: 'payload-jobs',\n data,\n db,\n fields: collection.flattenedFields,\n ignoreResult: returning === false,\n operation: 'update',\n req,\n tableName,\n })\n\n return returning === false ? null : [result]\n }\n\n const jobs = await findMany({\n adapter: this,\n collectionSlug: 'payload-jobs',\n fields: collection.flattenedFields,\n limit: id ? 1 : limit,\n pagination: false,\n req,\n sort,\n tableName,\n where: whereToUse,\n })\n if (!jobs.docs.length) {\n return []\n }\n\n const db = getPrimaryDb(this, await getTransaction(this, req))\n\n const results = []\n\n // TODO: We need to batch this to reduce the amount of db calls. This can get very slow if we are updating a lot of rows.\n for (const job of jobs.docs) {\n const updateData = useOptimizedUpsertRow\n ? data\n : {\n ...job,\n ...data,\n }\n\n const result = await upsertRow({\n id: job.id,\n adapter: this,\n collectionSlug: 'payload-jobs',\n data: updateData,\n db,\n fields: collection.flattenedFields,\n ignoreResult: returning === false,\n operation: 'update',\n req,\n tableName,\n })\n\n results.push(result)\n }\n\n if (returning === false) {\n return null\n }\n\n return results\n}\n"],"names":["toSnakeCase","findMany","upsertRow","shouldUseOptimizedUpsertRow","getPrimaryDb","getTransaction","updateJobs","updateMany","id","data","limit","limitArg","req","returning","sort","sortArg","where","whereArg","log","length","whereToUse","equals","collection","payload","collections","config","tableName","tableNameMap","get","slug","undefined","defaultSort","useOptimizedUpsertRow","fields","flattenedFields","db","result","adapter","collectionSlug","ignoreResult","operation","jobs","pagination","docs","results","job","updateData","push"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,2BAA2B,QAAQ,6CAA4C;AACxF,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,MAAMC,aAAyB,eAAeC,WAEnD,EAAEC,EAAE,EAAEC,IAAI,EAAEC,OAAOC,QAAQ,EAAEC,GAAG,EAAEC,SAAS,EAAEC,MAAMC,OAAO,EAAEC,OAAOC,QAAQ,EAAE;IAE7E,IACE,CAAER,MAAMS,KAAkBC,UAC1B,CAAEV,CAAAA,KAAKS,GAAG,IAAI,OAAOT,KAAKS,GAAG,KAAK,YAAY,WAAWT,KAAKS,GAAG,AAAD,GAChE;QACA,OAAOT,KAAKS,GAAG;IACjB;IAEA,MAAME,aAAoBZ,KAAK;QAAEA,IAAI;YAAEa,QAAQb;QAAG;IAAE,IAAIS;IACxD,MAAMP,QAAQF,KAAK,IAAIG;IAEvB,MAAMW,aAAa,IAAI,CAACC,OAAO,CAACC,WAAW,CAAC,eAAe,CAACC,MAAM;IAClE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAC5B,YAAYs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AAO;QACvB,OAAO;IACT;IAEA,OAAO+B;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/updateJobs.ts"],"sourcesContent":["import type { LibSQLDatabase } from 'drizzle-orm/libsql'\nimport type { UpdateJobs, Where } from 'payload'\n\nimport { and, inArray, isNull, lte, or } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { transformForWrite } from './transform/write/index.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { shouldUseOptimizedUpsertRow } from './upsertRow/shouldUseOptimizedUpsertRow.js'\nimport { getPrimaryDb } from './utilities/getPrimaryDb.js'\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { markWrite } from './utilities/readAfterWrite.js'\n\nconst isInitialJobClaim = (data: Record<string, unknown>): boolean =>\n typeof data.processingToken === 'string' &&\n typeof data.processingUntil === 'string' &&\n Object.keys(data).every(\n (field) => field === 'processingToken' || field === 'processingUntil' || field === 'updatedAt',\n )\n\nexport const updateJobs: UpdateJobs = async function updateMany(\n this: DrizzleAdapter,\n { id, data, limit: limitArg, req, returning, sort: sortArg, where: whereArg },\n) {\n if (\n !(data?.log as object[])?.length &&\n !(data.log && typeof data.log === 'object' && '$push' in data.log)\n ) {\n delete data.log\n }\n\n const whereToUse: Where = id ? { id: { equals: id } } : whereArg\n const limit = id ? 1 : limitArg\n\n const collection = this.payload.collections['payload-jobs'].config\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n const sort = sortArg !== undefined && sortArg !== null ? sortArg : collection.defaultSort\n\n const useOptimizedUpsertRow = shouldUseOptimizedUpsertRow({\n data,\n fields: collection.flattenedFields,\n })\n\n if (useOptimizedUpsertRow && id) {\n const db = getPrimaryDb(this, await getTransaction(this, req))\n\n const result = await upsertRow({\n id,\n adapter: this,\n collectionSlug: 'payload-jobs',\n data,\n db,\n fields: collection.flattenedFields,\n ignoreResult: returning === false,\n operation: 'update',\n req,\n tableName,\n })\n\n return returning === false ? null : [result]\n }\n\n const jobs = await findMany({\n adapter: this,\n collectionSlug: 'payload-jobs',\n fields: collection.flattenedFields,\n limit: id ? 1 : limit,\n pagination: false,\n req,\n sort,\n tableName,\n where: whereToUse,\n })\n if (!jobs.docs.length) {\n return []\n }\n\n const db = getPrimaryDb(this, await getTransaction(this, req))\n\n if (isInitialJobClaim(data)) {\n // Atomically claim jobs so multiple workers cannot pick up the same job.\n // We don't need FOR UPDATE SKIP LOCKED here because of the compare-and-swap-style update using processingUntil and processingToken.\n // The first update makes the where clause fail for other workers, so they cannot claim the same job.\n const _db = db as LibSQLDatabase\n const table = this.tables[tableName]\n const now = new Date().toISOString()\n const { row } = transformForWrite({\n adapter: this,\n data,\n enableAtomicWrites: true,\n fields: collection.flattenedFields,\n tableName,\n })\n\n if (typeof row.updatedAt === 'undefined' || row.updatedAt === null) {\n delete row.updatedAt\n }\n\n const jobIDs = jobs.docs.map((job) => job.id)\n const claimedRows = await _db\n .update(table)\n .set(row)\n .where(\n and(\n inArray(table.id, jobIDs),\n or(isNull(table.processingUntil), lte(table.processingUntil, now)),\n ),\n )\n .returning({ id: table.id })\n\n if (claimedRows.length) {\n markWrite(this)\n }\n\n if (returning === false) {\n return null\n }\n\n const claimedIDs = new Set(claimedRows.map(({ id }) => id))\n return jobs.docs.filter((job) => claimedIDs.has(job.id)).map((job) => ({ ...job, ...data }))\n }\n\n const results = []\n\n // TODO: We need to batch this to reduce the amount of db calls. This can get very slow if we are updating a lot of rows.\n for (const job of jobs.docs) {\n const updateData = useOptimizedUpsertRow\n ? data\n : {\n ...job,\n ...data,\n }\n\n const result = await upsertRow({\n id: job.id,\n adapter: this,\n collectionSlug: 'payload-jobs',\n data: updateData,\n db,\n fields: collection.flattenedFields,\n ignoreResult: returning === false,\n operation: 'update',\n req,\n tableName,\n })\n\n results.push(result)\n }\n\n if (returning === false) {\n return null\n }\n\n return results\n}\n"],"names":["and","inArray","isNull","lte","or","toSnakeCase","findMany","transformForWrite","upsertRow","shouldUseOptimizedUpsertRow","getPrimaryDb","getTransaction","markWrite","isInitialJobClaim","data","processingToken","processingUntil","Object","keys","every","field","updateJobs","updateMany","id","limit","limitArg","req","returning","sort","sortArg","where","whereArg","log","length","whereToUse","equals","collection","payload","collections","config","tableName","tableNameMap","get","slug","undefined","defaultSort","useOptimizedUpsertRow","fields","flattenedFields","db","result","adapter","collectionSlug","ignoreResult","operation","jobs","pagination","docs","_db","table","tables","now","Date","toISOString","row","enableAtomicWrites","updatedAt","jobIDs","map","job","claimedRows","update","set","claimedIDs","Set","filter","has","results","updateData","push"],"mappings":"AAGA,SAASA,GAAG,EAAEC,OAAO,EAAEC,MAAM,EAAEC,GAAG,EAAEC,EAAE,QAAQ,cAAa;AAC3D,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,2BAA2B,QAAQ,6CAA4C;AACxF,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,SAAS,QAAQ,gCAA+B;AAEzD,MAAMC,oBAAoB,CAACC,OACzB,OAAOA,KAAKC,eAAe,KAAK,YAChC,OAAOD,KAAKE,eAAe,KAAK,YAChCC,OAAOC,IAAI,CAACJ,MAAMK,KAAK,CACrB,CAACC,QAAUA,UAAU,qBAAqBA,UAAU,qBAAqBA,UAAU;AAGvF,OAAO,MAAMC,aAAyB,eAAeC,WAEnD,EAAEC,EAAE,EAAET,IAAI,EAAEU,OAAOC,QAAQ,EAAEC,GAAG,EAAEC,SAAS,EAAEC,MAAMC,OAAO,EAAEC,OAAOC,QAAQ,EAAE;IAE7E,IACE,CAAEjB,MAAMkB,KAAkBC,UAC1B,CAAEnB,CAAAA,KAAKkB,GAAG,IAAI,OAAOlB,KAAKkB,GAAG,KAAK,YAAY,WAAWlB,KAAKkB,GAAG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be,IAAI8C,IAAI9C,EAAE;YACV4B,SAAS,IAAI;YACbC,gBAAgB;YAChBtC,MAAMgE;YACN7B;YACAF,QAAQX,WAAWY,eAAe;YAClCK,cAAc1B,cAAc;YAC5B2B,WAAW;YACX5B;YACAc;QACF;QAEAqC,QAAQE,IAAI,CAAC7B;IACf;IAEA,IAAIvB,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,OAAOkD;AACT,EAAC"}
@@ -0,0 +1,6 @@
1
+ import type { DynamicMigrationTemplate } from 'payload';
2
+ export declare const buildDynamicPredefinedJobsProcessingLeaseMigration: ({ dialect, packageName, }: {
3
+ dialect: 'postgres' | 'sqlite';
4
+ packageName: string;
5
+ }) => DynamicMigrationTemplate;
6
+ //# sourceMappingURL=jobsProcessingLeaseMigration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobsProcessingLeaseMigration.d.ts","sourceRoot":"","sources":["../../src/utilities/jobsProcessingLeaseMigration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAqEvD,eAAO,MAAM,kDAAkD,8BAG5D;IACD,OAAO,EAAE,UAAU,GAAG,QAAQ,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAA;CACpB,KAAG,wBAwCH,CAAA"}
@@ -0,0 +1,64 @@
1
+ import { readdirSync, readFileSync, writeFileSync } from 'fs';
2
+ import path from 'path';
3
+ import toSnakeCase from 'to-snake-case';
4
+ const getDefaultIndexName = (name)=>{
5
+ const suffix = '_idx';
6
+ return `${name.slice(0, 60 - suffix.length)}${suffix}`;
7
+ };
8
+ const getIndexName = ({ fallbackFieldName, indexes, on, tableName })=>{
9
+ const matchingIndex = Object.values(indexes ?? {}).find((index)=>index.on === on);
10
+ return matchingIndex?.name ?? getDefaultIndexName(`${tableName}_${fallbackFieldName}`);
11
+ };
12
+ const getLegacyProcessingIndexName = ({ filePath, tableName })=>{
13
+ const latestSnapshotFile = readdirSync(path.dirname(filePath)).filter((file)=>file.endsWith('.json')).sort().reverse()[0];
14
+ if (latestSnapshotFile) {
15
+ const snapshot = JSON.parse(readFileSync(path.join(path.dirname(filePath), latestSnapshotFile), 'utf8'));
16
+ const table = Object.values(snapshot.tables ?? {}).find(({ name })=>name === tableName);
17
+ const processingIndex = Object.values(table?.indexes ?? {}).find((index)=>index.columns?.some(({ expression })=>expression === 'processing'));
18
+ if (processingIndex?.name) {
19
+ return processingIndex.name;
20
+ }
21
+ }
22
+ return getDefaultIndexName(`${tableName}_processing`);
23
+ };
24
+ export const buildDynamicPredefinedJobsProcessingLeaseMigration = ({ dialect, packageName })=>{
25
+ return async ({ filePath, payload })=>{
26
+ const adapter = payload.db;
27
+ const tableName = adapter.tableNameMap.get(toSnakeCase('payload-jobs'));
28
+ if (!tableName) {
29
+ throw new Error('Could not find the payload-jobs database table');
30
+ }
31
+ const rawTable = adapter.rawTables[tableName];
32
+ const newIndexName = getIndexName({
33
+ fallbackFieldName: 'processing_until',
34
+ indexes: rawTable?.indexes,
35
+ on: 'processingUntil',
36
+ tableName
37
+ });
38
+ const oldIndexName = getLegacyProcessingIndexName({
39
+ filePath,
40
+ tableName
41
+ });
42
+ const schemaName = dialect === 'postgres' ? adapter.schemaName ?? 'public' : undefined;
43
+ const drizzleSnapshot = await adapter.requireDrizzleKit().generateDrizzleJson(adapter.schema);
44
+ writeFileSync(`${filePath}.json`, JSON.stringify(drizzleSnapshot, null, 2));
45
+ const sharedArgs = `
46
+ db,
47
+ newIndexName: ${JSON.stringify(newIndexName)},
48
+ oldIndexName: ${JSON.stringify(oldIndexName)},
49
+ schemaName: ${JSON.stringify(schemaName)},
50
+ sql,
51
+ tableName: ${JSON.stringify(tableName)},`;
52
+ return {
53
+ downSQL: `await migrateJobsProcessingLease({${sharedArgs}
54
+ direction: 'down',
55
+ })`,
56
+ imports: `import { migrateJobsProcessingLease } from '${packageName}/migration-utils'`,
57
+ upSQL: `await migrateJobsProcessingLease({${sharedArgs}
58
+ direction: 'up',
59
+ })`
60
+ };
61
+ };
62
+ };
63
+
64
+ //# sourceMappingURL=jobsProcessingLeaseMigration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/jobsProcessingLeaseMigration.ts"],"sourcesContent":["import type { DynamicMigrationTemplate } from 'payload'\n\nimport { readdirSync, readFileSync, writeFileSync } from 'fs'\nimport path from 'path'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter, RawIndex } from '../types.js'\n\ntype SnapshotIndex = {\n columns?: { expression?: string }[]\n name?: string\n}\n\ntype SnapshotTable = {\n indexes?: Record<string, SnapshotIndex>\n name?: string\n}\n\nconst getDefaultIndexName = (name: string): string => {\n const suffix = '_idx'\n\n return `${name.slice(0, 60 - suffix.length)}${suffix}`\n}\n\nconst getIndexName = ({\n fallbackFieldName,\n indexes,\n on,\n tableName,\n}: {\n fallbackFieldName: string\n indexes?: Record<string, RawIndex>\n on: string\n tableName: string\n}): string => {\n const matchingIndex = Object.values(indexes ?? {}).find((index) => index.on === on)\n\n return matchingIndex?.name ?? getDefaultIndexName(`${tableName}_${fallbackFieldName}`)\n}\n\nconst getLegacyProcessingIndexName = ({\n filePath,\n tableName,\n}: {\n filePath: string\n tableName: string\n}): string => {\n const latestSnapshotFile = readdirSync(path.dirname(filePath))\n .filter((file) => file.endsWith('.json'))\n .sort()\n .reverse()[0]\n\n if (latestSnapshotFile) {\n const snapshot = JSON.parse(\n readFileSync(path.join(path.dirname(filePath), latestSnapshotFile), 'utf8'),\n ) as { tables?: Record<string, SnapshotTable> }\n const table = Object.values(snapshot.tables ?? {}).find(({ name }) => name === tableName)\n const processingIndex = Object.values(table?.indexes ?? {}).find((index) =>\n index.columns?.some(({ expression }) => expression === 'processing'),\n )\n\n if (processingIndex?.name) {\n return processingIndex.name\n }\n }\n\n return getDefaultIndexName(`${tableName}_processing`)\n}\n\nexport const buildDynamicPredefinedJobsProcessingLeaseMigration = ({\n dialect,\n packageName,\n}: {\n dialect: 'postgres' | 'sqlite'\n packageName: string\n}): DynamicMigrationTemplate => {\n return async ({ filePath, payload }) => {\n const adapter = payload.db as DrizzleAdapter\n const tableName = adapter.tableNameMap.get(toSnakeCase('payload-jobs'))\n\n if (!tableName) {\n throw new Error('Could not find the payload-jobs database table')\n }\n\n const rawTable = adapter.rawTables[tableName]\n const newIndexName = getIndexName({\n fallbackFieldName: 'processing_until',\n indexes: rawTable?.indexes,\n on: 'processingUntil',\n tableName,\n })\n const oldIndexName = getLegacyProcessingIndexName({ filePath, tableName })\n const schemaName = dialect === 'postgres' ? (adapter.schemaName ?? 'public') : undefined\n const drizzleSnapshot = await adapter.requireDrizzleKit().generateDrizzleJson(adapter.schema)\n\n writeFileSync(`${filePath}.json`, JSON.stringify(drizzleSnapshot, null, 2))\n\n const sharedArgs = `\n db,\n newIndexName: ${JSON.stringify(newIndexName)},\n oldIndexName: ${JSON.stringify(oldIndexName)},\n schemaName: ${JSON.stringify(schemaName)},\n sql,\n tableName: ${JSON.stringify(tableName)},`\n\n return {\n downSQL: `await migrateJobsProcessingLease({${sharedArgs}\n direction: 'down',\n })`,\n imports: `import { migrateJobsProcessingLease } from '${packageName}/migration-utils'`,\n upSQL: `await migrateJobsProcessingLease({${sharedArgs}\n direction: 'up',\n })`,\n }\n }\n}\n"],"names":["readdirSync","readFileSync","writeFileSync","path","toSnakeCase","getDefaultIndexName","name","suffix","slice","length","getIndexName","fallbackFieldName","indexes","on","tableName","matchingIndex","Object","values","find","index","getLegacyProcessingIndexName","filePath","latestSnapshotFile","dirname","filter","file","endsWith","sort","reverse","snapshot","JSON","parse","join","table","tables","processingIndex","columns","some","expression","buildDynamicPredefinedJobsProcessingLeaseMigration","dialect","packageName","payload","adapter","db","tableNameMap","get","Error","rawTable","rawTables","newIndexName","oldIndexName","schemaName","undefined","drizzleSnapshot","requireDrizzleKit","generateDrizzleJson","schema","stringify","sharedArgs","downSQL","imports","upSQL"],"mappings":"AAEA,SAASA,WAAW,EAAEC,YAAY,EAAEC,aAAa,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AEA,OAAO,MAAMyB,qDAAqD,CAAC,EACjEC,OAAO,EACPC,WAAW,EAIZ;IACC,OAAO,OAAO,EAAEpB,QAAQ,EAAEqB,OAAO,EAAE;QACjC,MAAMC,UAAUD,QAAQE,EAAE;QAC1B,MAAM9B,YAAY6B,QAAQE,YAAY,CAACC,GAAG,CAAC1C,YAAY;QAEvD,IAAI,CAACU,WAAW;YACd,MAAM,IAAIiC,MAAM;QAClB;QAEA,MAAMC,WAAWL,QAAQM,SAAS,CAACnC,UAAU;QAC7C,MAAMoC,eAAexC,aAAa;YAChCC,mBAAmB;YACnBC,SAASoC,UAAUpC;YACnBC,IAAI;YACJC;QACF;QACA,MAAMqC,eAAe/B,6BAA6B;YAAEC;YAAUP;QAAU;QACxE,MAAMsC,aAAaZ,YAAY,aAAcG,QAAQS,UAAU,IAAI,WAAYC;QAC/E,MAAMC,kBAAkB,MAAMX,QAAQY,iBAAiB,GAAGC,mBAAmB,CAACb,QAAQc,MAAM;QAE5FvD,cAAc,GAAGmB,SAAS,KAAK,CAAC,EAAES,KAAK4B,SAAS,CAACJ,iBAAiB,MAAM;QAExE,MAAMK,aAAa,CAAC;;kBAEN,EAAE7B,KAAK4B,SAAS,CAACR,cAAc;kBAC/B,EAAEpB,KAAK4B,SAAS,CAACP,cAAc;gBACjC,EAAErB,KAAK4B,SAAS,CAACN,YAAY;;eAE9B,EAAEtB,KAAK4B,SAAS,CAAC5C,WAAW,CAAC,CAAC;QAEzC,OAAO;YACL8C,SAAS,CAAC,kCAAkC,EAAED,WAAW;;IAE3D,CAAC;YACCE,SAAS,CAAC,4CAA4C,EAAEpB,YAAY,iBAAiB,CAAC;YACtFqB,OAAO,CAAC,kCAAkC,EAAEH,WAAW;;IAEzD,CAAC;QACD;IACF;AACF,EAAC"}
@@ -0,0 +1,186 @@
1
+ import { createClient } from '@libsql/client';
2
+ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
3
+ import { tmpdir } from 'os';
4
+ import path from 'path';
5
+ import { afterEach, describe, expect, it, vi } from 'vitest';
6
+ import { migratePostgresJobsProcessingLease } from '../postgres/predefinedMigrations/jobs-processing-lease/index.js';
7
+ import { migrateSqliteJobsProcessingLease } from '../sqlite/predefinedMigrations/jobs-processing-lease/index.js';
8
+ import { buildDynamicPredefinedJobsProcessingLeaseMigration } from './jobsProcessingLeaseMigration.js';
9
+ describe('jobs processing lease predefined migration', ()=>{
10
+ let client;
11
+ const temporaryDirectories = [];
12
+ afterEach(()=>{
13
+ client?.close();
14
+ client = undefined;
15
+ for (const directory of temporaryDirectories){
16
+ rmSync(directory, {
17
+ force: true,
18
+ recursive: true
19
+ });
20
+ }
21
+ temporaryDirectories.length = 0;
22
+ });
23
+ it('should migrate SQLite job data up and down', async ()=>{
24
+ client = createClient({
25
+ url: ':memory:'
26
+ });
27
+ await client.execute('CREATE TABLE "custom_jobs" ("id" integer primary key, "processing" integer DEFAULT false)');
28
+ await client.execute('CREATE INDEX "custom_jobs_processing_idx" ON "custom_jobs" ("processing")');
29
+ await client.execute('INSERT INTO "custom_jobs" ("id", "processing") VALUES (1, true), (2, false)');
30
+ const db = {
31
+ run: (statement)=>client.execute(statement)
32
+ };
33
+ const sql = {
34
+ raw: (statement)=>statement
35
+ };
36
+ await migrateSqliteJobsProcessingLease({
37
+ db,
38
+ direction: 'up',
39
+ newIndexName: 'custom_jobs_processing_until_idx',
40
+ oldIndexName: 'custom_jobs_processing_idx',
41
+ sql,
42
+ tableName: 'custom_jobs'
43
+ });
44
+ const migratedJobs = await client.execute('SELECT "id", "processing_until", "processing_token" FROM "custom_jobs" ORDER BY "id"');
45
+ expect(migratedJobs.rows).toEqual([
46
+ {
47
+ id: 1,
48
+ processing_token: null,
49
+ processing_until: '1970-01-01T00:00:00.000Z'
50
+ },
51
+ {
52
+ id: 2,
53
+ processing_token: null,
54
+ processing_until: null
55
+ }
56
+ ]);
57
+ await migrateSqliteJobsProcessingLease({
58
+ db,
59
+ direction: 'down',
60
+ newIndexName: 'custom_jobs_processing_until_idx',
61
+ oldIndexName: 'custom_jobs_processing_idx',
62
+ sql,
63
+ tableName: 'custom_jobs'
64
+ });
65
+ const restoredJobs = await client.execute('SELECT "id", "processing" FROM "custom_jobs" ORDER BY "id"');
66
+ expect(restoredJobs.rows).toEqual([
67
+ {
68
+ id: 1,
69
+ processing: 1
70
+ },
71
+ {
72
+ id: 2,
73
+ processing: 0
74
+ }
75
+ ]);
76
+ const restoredColumns = await client.execute('PRAGMA table_info("custom_jobs")');
77
+ expect(restoredColumns.rows.map((column)=>column.name)).not.toContain('processing_token');
78
+ });
79
+ it('should produce PostgreSQL statements with quoted custom names', async ()=>{
80
+ const execute = vi.fn().mockResolvedValue(undefined);
81
+ await migratePostgresJobsProcessingLease({
82
+ db: {
83
+ execute
84
+ },
85
+ direction: 'up',
86
+ newIndexName: 'custom_jobs_processing_until_idx',
87
+ oldIndexName: 'custom_jobs_processing_idx',
88
+ schemaName: 'custom_schema',
89
+ sql: {
90
+ raw: (statement)=>statement
91
+ },
92
+ tableName: 'custom_jobs'
93
+ });
94
+ expect(execute.mock.calls.map(([statement])=>statement)).toEqual([
95
+ 'ALTER TABLE "custom_schema"."custom_jobs" ADD COLUMN "processing_until" timestamp(3) with time zone',
96
+ 'ALTER TABLE "custom_schema"."custom_jobs" ADD COLUMN "processing_token" varchar',
97
+ 'UPDATE "custom_schema"."custom_jobs" SET "processing_until" = \'1970-01-01 00:00:00+00\' WHERE "processing" = true',
98
+ 'DROP INDEX IF EXISTS "custom_schema"."custom_jobs_processing_idx"',
99
+ 'ALTER TABLE "custom_schema"."custom_jobs" DROP COLUMN "processing"',
100
+ 'CREATE INDEX "custom_jobs_processing_until_idx" ON "custom_schema"."custom_jobs" USING btree ("processing_until")'
101
+ ]);
102
+ execute.mockClear();
103
+ await migratePostgresJobsProcessingLease({
104
+ db: {
105
+ execute
106
+ },
107
+ direction: 'down',
108
+ newIndexName: 'custom_jobs_processing_until_idx',
109
+ oldIndexName: 'custom_jobs_processing_idx',
110
+ schemaName: 'custom_schema',
111
+ sql: {
112
+ raw: (statement)=>statement
113
+ },
114
+ tableName: 'custom_jobs'
115
+ });
116
+ expect(execute.mock.calls.map(([statement])=>statement)).toContain('ALTER TABLE "custom_schema"."custom_jobs" DROP COLUMN "processing_token"');
117
+ });
118
+ it('should write a Drizzle snapshot and generate adapter-specific migration code', async ()=>{
119
+ const temporaryDirectory = mkdtempSync(path.join(tmpdir(), 'payload-jobs-migration-'));
120
+ temporaryDirectories.push(temporaryDirectory);
121
+ const filePath = path.join(temporaryDirectory, 'migration');
122
+ writeFileSync(path.join(temporaryDirectory, 'previous.json'), JSON.stringify({
123
+ tables: {
124
+ jobs: {
125
+ indexes: {
126
+ legacy: {
127
+ columns: [
128
+ {
129
+ expression: 'processing'
130
+ }
131
+ ],
132
+ name: 'legacy_processing_index'
133
+ }
134
+ },
135
+ name: 'custom_jobs'
136
+ }
137
+ }
138
+ }));
139
+ const payload = {
140
+ db: {
141
+ rawTables: {
142
+ custom_jobs: {
143
+ indexes: {
144
+ processingUntil: {
145
+ name: 'custom_jobs_processing_until_idx',
146
+ on: 'processingUntil'
147
+ }
148
+ }
149
+ }
150
+ },
151
+ requireDrizzleKit: ()=>({
152
+ generateDrizzleJson: vi.fn().mockResolvedValue({
153
+ version: 'test-snapshot'
154
+ })
155
+ }),
156
+ schema: {},
157
+ schemaName: 'custom_schema',
158
+ tableNameMap: new Map([
159
+ [
160
+ 'payload_jobs',
161
+ 'custom_jobs'
162
+ ]
163
+ ])
164
+ }
165
+ };
166
+ const dynamic = buildDynamicPredefinedJobsProcessingLeaseMigration({
167
+ dialect: 'postgres',
168
+ packageName: '@payloadcms/db-postgres'
169
+ });
170
+ const migration = await dynamic({
171
+ filePath,
172
+ payload
173
+ });
174
+ expect(existsSync(`${filePath}.json`)).toBe(true);
175
+ expect(JSON.parse(readFileSync(`${filePath}.json`, 'utf8'))).toEqual({
176
+ version: 'test-snapshot'
177
+ });
178
+ expect(migration.imports).toContain('@payloadcms/db-postgres/migration-utils');
179
+ expect(migration.upSQL).toContain("direction: 'up'");
180
+ expect(migration.upSQL).toContain('custom_jobs_processing_until_idx');
181
+ expect(migration.upSQL).toContain('legacy_processing_index');
182
+ expect(migration.downSQL).toContain("direction: 'down'");
183
+ });
184
+ });
185
+
186
+ //# sourceMappingURL=jobsProcessingLeaseMigration.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/jobsProcessingLeaseMigration.spec.ts"],"sourcesContent":["import type { Client } from '@libsql/client'\nimport type { Payload } from 'payload'\n\nimport { createClient } from '@libsql/client'\nimport { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs'\nimport { tmpdir } from 'os'\nimport path from 'path'\nimport { afterEach, describe, expect, it, vi } from 'vitest'\n\nimport { migratePostgresJobsProcessingLease } from '../postgres/predefinedMigrations/jobs-processing-lease/index.js'\nimport { migrateSqliteJobsProcessingLease } from '../sqlite/predefinedMigrations/jobs-processing-lease/index.js'\nimport { buildDynamicPredefinedJobsProcessingLeaseMigration } from './jobsProcessingLeaseMigration.js'\n\ndescribe('jobs processing lease predefined migration', () => {\n let client: Client | undefined\n const temporaryDirectories: string[] = []\n\n afterEach(() => {\n client?.close()\n client = undefined\n\n for (const directory of temporaryDirectories) {\n rmSync(directory, { force: true, recursive: true })\n }\n temporaryDirectories.length = 0\n })\n\n it('should migrate SQLite job data up and down', async () => {\n client = createClient({ url: ':memory:' })\n await client.execute(\n 'CREATE TABLE \"custom_jobs\" (\"id\" integer primary key, \"processing\" integer DEFAULT false)',\n )\n await client.execute(\n 'CREATE INDEX \"custom_jobs_processing_idx\" ON \"custom_jobs\" (\"processing\")',\n )\n await client.execute(\n 'INSERT INTO \"custom_jobs\" (\"id\", \"processing\") VALUES (1, true), (2, false)',\n )\n\n const db = { run: (statement: unknown) => client!.execute(statement as string) }\n const sql = { raw: (statement: string) => statement }\n\n await migrateSqliteJobsProcessingLease({\n db,\n direction: 'up',\n newIndexName: 'custom_jobs_processing_until_idx',\n oldIndexName: 'custom_jobs_processing_idx',\n sql,\n tableName: 'custom_jobs',\n })\n\n const migratedJobs = await client.execute(\n 'SELECT \"id\", \"processing_until\", \"processing_token\" FROM \"custom_jobs\" ORDER BY \"id\"',\n )\n expect(migratedJobs.rows).toEqual([\n { id: 1, processing_token: null, processing_until: '1970-01-01T00:00:00.000Z' },\n { id: 2, processing_token: null, processing_until: null },\n ])\n\n await migrateSqliteJobsProcessingLease({\n db,\n direction: 'down',\n newIndexName: 'custom_jobs_processing_until_idx',\n oldIndexName: 'custom_jobs_processing_idx',\n sql,\n tableName: 'custom_jobs',\n })\n\n const restoredJobs = await client.execute(\n 'SELECT \"id\", \"processing\" FROM \"custom_jobs\" ORDER BY \"id\"',\n )\n expect(restoredJobs.rows).toEqual([\n { id: 1, processing: 1 },\n { id: 2, processing: 0 },\n ])\n const restoredColumns = await client.execute('PRAGMA table_info(\"custom_jobs\")')\n expect(restoredColumns.rows.map((column) => column.name)).not.toContain('processing_token')\n })\n\n it('should produce PostgreSQL statements with quoted custom names', async () => {\n const execute = vi.fn().mockResolvedValue(undefined)\n\n await migratePostgresJobsProcessingLease({\n db: { execute },\n direction: 'up',\n newIndexName: 'custom_jobs_processing_until_idx',\n oldIndexName: 'custom_jobs_processing_idx',\n schemaName: 'custom_schema',\n sql: { raw: (statement: string) => statement },\n tableName: 'custom_jobs',\n })\n\n expect(execute.mock.calls.map(([statement]) => statement)).toEqual([\n 'ALTER TABLE \"custom_schema\".\"custom_jobs\" ADD COLUMN \"processing_until\" timestamp(3) with time zone',\n 'ALTER TABLE \"custom_schema\".\"custom_jobs\" ADD COLUMN \"processing_token\" varchar',\n 'UPDATE \"custom_schema\".\"custom_jobs\" SET \"processing_until\" = \\'1970-01-01 00:00:00+00\\' WHERE \"processing\" = true',\n 'DROP INDEX IF EXISTS \"custom_schema\".\"custom_jobs_processing_idx\"',\n 'ALTER TABLE \"custom_schema\".\"custom_jobs\" DROP COLUMN \"processing\"',\n 'CREATE INDEX \"custom_jobs_processing_until_idx\" ON \"custom_schema\".\"custom_jobs\" USING btree (\"processing_until\")',\n ])\n\n execute.mockClear()\n await migratePostgresJobsProcessingLease({\n db: { execute },\n direction: 'down',\n newIndexName: 'custom_jobs_processing_until_idx',\n oldIndexName: 'custom_jobs_processing_idx',\n schemaName: 'custom_schema',\n sql: { raw: (statement: string) => statement },\n tableName: 'custom_jobs',\n })\n\n expect(execute.mock.calls.map(([statement]) => statement)).toContain(\n 'ALTER TABLE \"custom_schema\".\"custom_jobs\" DROP COLUMN \"processing_token\"',\n )\n })\n\n it('should write a Drizzle snapshot and generate adapter-specific migration code', async () => {\n const temporaryDirectory = mkdtempSync(path.join(tmpdir(), 'payload-jobs-migration-'))\n temporaryDirectories.push(temporaryDirectory)\n const filePath = path.join(temporaryDirectory, 'migration')\n writeFileSync(\n path.join(temporaryDirectory, 'previous.json'),\n JSON.stringify({\n tables: {\n jobs: {\n indexes: {\n legacy: {\n columns: [{ expression: 'processing' }],\n name: 'legacy_processing_index',\n },\n },\n name: 'custom_jobs',\n },\n },\n }),\n )\n const payload = {\n db: {\n rawTables: {\n custom_jobs: {\n indexes: {\n processingUntil: {\n name: 'custom_jobs_processing_until_idx',\n on: 'processingUntil',\n },\n },\n },\n },\n requireDrizzleKit: () => ({\n generateDrizzleJson: vi.fn().mockResolvedValue({ version: 'test-snapshot' }),\n }),\n schema: {},\n schemaName: 'custom_schema',\n tableNameMap: new Map([['payload_jobs', 'custom_jobs']]),\n },\n } as unknown as Payload\n\n const dynamic = buildDynamicPredefinedJobsProcessingLeaseMigration({\n dialect: 'postgres',\n packageName: '@payloadcms/db-postgres',\n })\n const migration = await dynamic({ filePath, payload })\n\n expect(existsSync(`${filePath}.json`)).toBe(true)\n expect(JSON.parse(readFileSync(`${filePath}.json`, 'utf8'))).toEqual({\n version: 'test-snapshot',\n })\n expect(migration.imports).toContain('@payloadcms/db-postgres/migration-utils')\n expect(migration.upSQL).toContain(\"direction: 'up'\")\n expect(migration.upSQL).toContain('custom_jobs_processing_until_idx')\n expect(migration.upSQL).toContain('legacy_processing_index')\n expect(migration.downSQL).toContain(\"direction: 'down'\")\n })\n})\n"],"names":["createClient","existsSync","mkdtempSync","readFileSync","rmSync","writeFileSync","tmpdir","path","afterEach","describe","expect","it","vi","migratePostgresJobsProcessingLease","migrateSqliteJobsProcessingLease","buildDynamicPredefinedJobsProcessingLeaseMigration","client","temporaryDirectories","close","undefined","directory","force","recursive","length","url","execute","db","run","statement","sql","raw","direction","newIndexName","oldIndexName","tableName","migratedJobs","rows","toEqual","id","processing_token","processing_until","restoredJobs","processing","restoredColumns","map","column","name","not","toContain","fn","mockResolvedValue","schemaName","mock","calls","mockClear","temporaryDirectory","join","push","filePath","JSON","stringify","tables","jobs","indexes","legacy","columns","expression","payload","rawTables","custom_jobs","processingUntil","on","requireDrizzleKit","generateDrizzleJson","version","schema","tableNameMap","Map","dynamic","dialect","packageName","migration","toBe","parse","imports","upSQL","downSQL"],"mappings":"AAGA,SAASA,YAAY,QAAQ,iBAAgB;AAC7C,SAASC,UAAU,EAAEC,WAAW,EAAEC,YAAY,EAAEC,MAAM,EAAEC,aAAa,QAAQ,KAAI;AACjF,SAASC,MAAM,QAAQ,KAAI;AAC3B,OAAOC,UAAU,OAAM;AACvB,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,SAAQ;AAE5D,SAASC,kCAAkC,QAAQ,kEAAiE;AACpH,SAASC,gCAAgC,QAAQ,gEAA+D;AAChH,SAASC,kDAAkD,QAAQ,oCAAmC;AAEtGN,SAAS,8CAA8C;IACrD,IAAIO;IACJ,MAAMC,uBAAiC,EAAE;IAEzCT,UAAU;QACRQ,QAAQE;QACRF,SAASG;QAET,KAAK,MAAMC,aAAaH,qBAAsB;YAC5Cb,OAAOgB,WAAW;gBAAEC,OAAO;gBAAMC,WAAW;YAAK;QACnD;QACAL,qBAAqBM,MAAM,GAAG;IAChC;IAEAZ,GA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BAAC;wBAAgB;qBAAc;iBAAC;YACzD;QACF;QAEA,MAAMC,UAAU/D,mDAAmD;YACjEgE,SAAS;YACTC,aAAa;QACf;QACA,MAAMC,YAAY,MAAMH,QAAQ;YAAEpB;YAAUS;QAAQ;QAEpDzD,OAAOT,WAAW,GAAGyD,SAAS,KAAK,CAAC,GAAGwB,IAAI,CAAC;QAC5CxE,OAAOiD,KAAKwB,KAAK,CAAChF,aAAa,GAAGuD,SAAS,KAAK,CAAC,EAAE,UAAUrB,OAAO,CAAC;YACnEqC,SAAS;QACX;QACAhE,OAAOuE,UAAUG,OAAO,EAAEpC,SAAS,CAAC;QACpCtC,OAAOuE,UAAUI,KAAK,EAAErC,SAAS,CAAC;QAClCtC,OAAOuE,UAAUI,KAAK,EAAErC,SAAS,CAAC;QAClCtC,OAAOuE,UAAUI,KAAK,EAAErC,SAAS,CAAC;QAClCtC,OAAOuE,UAAUK,OAAO,EAAEtC,SAAS,CAAC;IACtC;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/drizzle",
3
- "version": "4.0.0-internal.078835b",
3
+ "version": "4.0.0-internal.0b9bec1",
4
4
  "description": "A library of shared functions used by different payload database adapters",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -55,10 +55,10 @@
55
55
  "@types/pg": "8.20.0",
56
56
  "@types/to-snake-case": "1.0.0",
57
57
  "@payloadcms/eslint-config": "3.28.0",
58
- "payload": "4.0.0-internal.078835b"
58
+ "payload": "4.0.0-internal.0b9bec1"
59
59
  },
60
60
  "peerDependencies": {
61
- "payload": "4.0.0-internal.078835b"
61
+ "payload": "4.0.0-internal.0b9bec1"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "pnpm build:swc && pnpm build:types",