@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.js CHANGED
@@ -423,10 +423,10 @@ var DrizzlePgStateStore = class _DrizzlePgStateStore {
423
423
  }
424
424
  async tryAdmitSingleton(runId, tag, workflow, limit, retryWakeAt) {
425
425
  return this.db.transaction(async (tx) => {
426
- const where = and(eq(durableWorkflowRuns.workflow, workflow), inArray(durableWorkflowRuns.status, SINGLETON_ACTIVE_STATUSES), this.scope());
427
- await tx.update(durableWorkflowRuns).set({
428
- workflow
429
- }).where(where);
426
+ const where = and(eq(durableWorkflowRuns.workflow, workflow), inArray(durableWorkflowRuns.status, SINGLETON_ACTIVE_STATUSES), hasTag(tag), this.scope());
427
+ await tx.select({
428
+ id: durableWorkflowRuns.id
429
+ }).from(durableWorkflowRuns).where(where).orderBy(asc(durableWorkflowRuns.id)).for("update");
430
430
  const rows = await tx.select().from(durableWorkflowRuns).where(where);
431
431
  const runs = rows.map(fromRunRow);
432
432
  const tags = singletonAdmissionTags(runs, runId, tag, workflow, limit);
@@ -1102,6 +1102,9 @@ async function reindexAttributes(db, runId, attributes) {
1102
1102
  }
1103
1103
  __name(reindexAttributes, "reindexAttributes");
1104
1104
  async function deleteRunsCascade(db, runIds) {
1105
+ await db.select({
1106
+ id: durableWorkflowRuns.id
1107
+ }).from(durableWorkflowRuns).where(inArray(durableWorkflowRuns.id, runIds)).orderBy(asc(durableWorkflowRuns.id)).for("update");
1105
1108
  await db.delete(durableStepCheckpoints).where(inArray(durableStepCheckpoints.runId, runIds));
1106
1109
  await db.delete(durableSignalWaiters).where(inArray(durableSignalWaiters.runId, runIds));
1107
1110
  await db.delete(durableRunAttributes).where(inArray(durableRunAttributes.runId, runIds));