fix(db): exempt credit-only orgs from canceled retention - #2979
Conversation
Canceled orgs with active usage credits were swept as unpaid after trial end. Exclude has_usage_credits from grace eligibility and retention warnings. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe migration adds retention helpers that exclude organizations with active usage credits from cleanup and warning alerts. The test suite adds a credit-funded canceled organization and verifies that its apps, versions, and retention state remain intact. ChangesCanceled retention exemption
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant RetentionSweep
participant SupabaseFunctions
participant pgmq
RetentionSweep->>SupabaseFunctions: request canceled-org retention alerts
SupabaseFunctions->>SupabaseFunctions: exclude usage-credit organizations
SupabaseFunctions->>pgmq: enqueue eligible retention alerts
pgmq-->>RetentionSweep: return queued count
Possibly related PRs
Suggested labels: Suggested reviewers: Comment |
Merging this PR will not alter performance
Comparing Footnotes
|
|
There was a problem hiding this comment.
Risk: high. Left a non-blocking comment — Bugbot passed with no findings, but this migration changes billing/retention eligibility for credit-funded orgs, which is above the low approval threshold. Human review needed; assigning reviewers.
Sent by Cursor Approval Agent: Pull Request Approver External





Summary (AI generated)
has_usage_creditsfromcanceled_org_ids_past_graceand retention warning queueFixes #2974
Motivation (AI generated)
#2929 retention only checked
stripe_info.status IN ('canceled','deleted'). Credit-only orgs staycanceledafter trial while actively paying with usage credits, so the sweep deleted their production bundles. #2789 already introducedhas_usage_credits_orgfor the CLI; retention never consulted the same flag.Business Impact (AI generated)
Stops deleting paying credit customers' apps/bundles. Protects credit billing path from false unpaid retention.
Test Plan (AI generated)
bun scripts/supabase-worktree.ts test db(includes64_test_canceled_org_version_cleanup.sql)canceled_org_ids_past_grace(90)/(95)in prod after migratef81009da-e037-4ad9-bfee-f6d2674d9bb9Generated with AI
Made with Cursor
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
Bug Fixes