@dudousxd/nestjs-durable-store-drizzle 0.24.6 → 0.24.7

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/pg/index.cjs CHANGED
@@ -463,10 +463,10 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
463
463
  }
464
464
  async tryAdmitSingleton(runId, tag, workflow, limit, retryWakeAt) {
465
465
  return this.db.transaction(async (tx) => {
466
- const where = (0, import_drizzle_orm4.and)((0, import_drizzle_orm4.eq)(durableWorkflowRuns.workflow, workflow), (0, import_drizzle_orm4.inArray)(durableWorkflowRuns.status, import_nestjs_durable_core.SINGLETON_ACTIVE_STATUSES), this.scope());
467
- await tx.update(durableWorkflowRuns).set({
468
- workflow
469
- }).where(where);
466
+ const where = (0, import_drizzle_orm4.and)((0, import_drizzle_orm4.eq)(durableWorkflowRuns.workflow, workflow), (0, import_drizzle_orm4.inArray)(durableWorkflowRuns.status, import_nestjs_durable_core.SINGLETON_ACTIVE_STATUSES), hasTag(tag), this.scope());
467
+ await tx.select({
468
+ id: durableWorkflowRuns.id
469
+ }).from(durableWorkflowRuns).where(where).orderBy((0, import_drizzle_orm4.asc)(durableWorkflowRuns.id)).for("update");
470
470
  const rows = await tx.select().from(durableWorkflowRuns).where(where);
471
471
  const runs = rows.map(fromRunRow);
472
472
  const tags = (0, import_nestjs_durable_core.singletonAdmissionTags)(runs, runId, tag, workflow, limit);
@@ -1142,6 +1142,9 @@ async function reindexAttributes(db, runId, attributes) {
1142
1142
  }
1143
1143
  __name(reindexAttributes, "reindexAttributes");
1144
1144
  async function deleteRunsCascade(db, runIds) {
1145
+ await db.select({
1146
+ id: durableWorkflowRuns.id
1147
+ }).from(durableWorkflowRuns).where((0, import_drizzle_orm4.inArray)(durableWorkflowRuns.id, runIds)).orderBy((0, import_drizzle_orm4.asc)(durableWorkflowRuns.id)).for("update");
1145
1148
  await db.delete(durableStepCheckpoints).where((0, import_drizzle_orm4.inArray)(durableStepCheckpoints.runId, runIds));
1146
1149
  await db.delete(durableSignalWaiters).where((0, import_drizzle_orm4.inArray)(durableSignalWaiters.runId, runIds));
1147
1150
  await db.delete(durableRunAttributes).where((0, import_drizzle_orm4.inArray)(durableRunAttributes.runId, runIds));