-
Notifications
You must be signed in to change notification settings - Fork 6
ops(plans): clean up existing universal plans (DB rows with no plan_accounts entry) #742
Copy link
Copy link
Closed
Labels
effort/mDaysDaysimpact/fewLimited audienceLimited audiencepr-createdA PR has been opened for this issue (dedup guard for the auto-PR loop)A PR has been opened for this issue (dedup guard for the auto-PR loop)pr-mergedThe PR for this issue has been mergedThe PR for this issue has been mergedpriority/p2Backlog-worthyBacklog-worthyseverity/lowMinor harmMinor harmtriagedItem has been triagedItem has been triagedtype/choreMaintenance / non-user-visibleMaintenance / non-user-visibleurgency/this-sprintWithin the current sprintWithin the current sprint
Description
Activity
Metadata
Metadata
Assignees
Labels
effort/mDaysDaysimpact/fewLimited audienceLimited audiencepr-createdA PR has been opened for this issue (dedup guard for the auto-PR loop)A PR has been opened for this issue (dedup guard for the auto-PR loop)pr-mergedThe PR for this issue has been mergedThe PR for this issue has been mergedpriority/p2Backlog-worthyBacklog-worthyseverity/lowMinor harmMinor harmtriagedItem has been triagedItem has been triagedtype/choreMaintenance / non-user-visibleMaintenance / non-user-visibleurgency/this-sprintWithin the current sprintWithin the current sprint
Context
PR "fix(plans): eliminate universal plans" closes the API hole that allowed
creating "universal plans" — rows in
purchase_planswith no matching row inplan_accounts. After that PR lands, the API rejects emptytarget_accountson
POST /api/plansand the modal Save button stays disabled until the userpicks at least one account.
That PR does NOT touch existing universal plans already in the DB. Those rows
predate the enforcement and need operator-driven cleanup. This issue tracks
the cleanup decision + execution.
Diagnostic
Run the read-only diagnostic to enumerate every universal plan currently in
the DB (count + IDs + names + creation dates + services):
psql "$DB_URL" -f scripts/list_universal_plans.sqlThe script's header documents the three cleanup options inline so you can
decide per plan without leaving psql.
Three cleanup options
(a) Delete
Use when the plan is genuinely orphaned — no consumer, no executions, never
used. Safest when the row predates any intentional use.
(b) Fan out
Attach every enabled
cloud_accountwhose provider matches the plan'sservicesmap. Mimics the historical "blank == all provider accounts"intent; concrete, explicit, and recoverable.
(c) Manual review
Pull the plan up in the UI, talk to the owner if known, and assign the right
account(s) via the (now-required-Target-Account) New/Edit Plan modal.
Recommended for plans with clear intent the SQL can't infer.
Recommendation
Default to (c) manual review per plan, unless the row is obviously orphaned
(zero executions, owner unreachable) — in which case (a) DELETE is fine. (b)
fan-out is safe but loud (creates a lot of plan_accounts rows in one go);
use it only after confirming the original intent.
Related
can be created.
buildListPlansQuerysouniversal plans appeared in the account-filtered list. After eliminate-
universal-plans merges + this cleanup completes, that branch is dead code.