Skip to content

fix(plans): open step rows orphaned before #1046 and scheduled steps of deleted plans #1048

Open

Description

@IAmJSD

Follow-up from #862 / #1046.

#1046 cancels a plan's open step rows (pending, notified, paused) inside DeletePurchasePlan, so deleting a plan no longer leaves approvable plan-less rows. Two cases are left over:

1. Rows orphaned before #1046

On existing deployments, plans deleted before #1046 left their open step rows with plan_id NULL (purchase_executions.plan_id is ON DELETE SET NULL). Token approval skips requirePlanStepCap and the approve-own plan-step rule when PlanID == "", so those rows can still be approved with no cap.

A backfill needs a reliable way to tell an orphaned plan step from an ad-hoc execution. No current column does that: step_number defaults to 1 for both. Options:

  • add a marker (for example source or a nullable deleted_plan_id) going forward, plus a one-off best-effort backfill;
  • cancel every open plan-less row older than a cutoff (this risks canceling legitimate ad-hoc rows);
  • leave them and document a manual cleanup query.

Any migration should take the next free number: 000126 is the highest on main, and the open #1020 and #1022 add 000127 and 000128.

2. scheduled rows of a deleted plan

#1046 deliberately leaves scheduled rows alone, because they were approved while the plan existed. They still fire at their scheduled time after the plan is deleted. Whether deleting a plan should also revoke its scheduled steps is a product decision.

No frontend change is implied either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions