Add script to remove partner self-referrals from ProgramApplicationEvent#3966
Add script to remove partner self-referrals from ProgramApplicationEvent#3966devkiran wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR adds a one-time maintenance script to remove self-referral relationships from the ChangesSelf-referral cleanup maintenance script
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/scripts/misc/remove-self-referrals.ts`:
- Line 41: The script calls main() without handling errors or disconnecting
Prisma; wrap the entrypoint so you call main().catch(err => {
processLogger/error or console.error(err); process.exitCode = 1; }).finally(()
=> prisma.$disconnect()) to ensure the Prisma pool is released and failures set
a non-zero exit code; use the existing main() function and the prisma instance
(prisma.$disconnect()) and set process.exitCode rather than immediate
process.exit to allow graceful teardown.
- Around line 12-16: Change the raw SQL to use Prisma's default unquoted
identifiers for the ProgramApplicationEvent fields (ensure the prisma.$queryRaw
call selects id, partnerId, referredByPartnerId, visitedAt without any
backtick/quoted identifiers) so it matches the MySQL schema and Prisma model,
and add failure handling for the script by appending a catch to the main
invocation—call main().catch(e => { console.error(e); process.exit(1); }) to
ensure errors are logged and the process exits; refer to prisma.$queryRaw,
ProgramApplicationEvent, programApplicationEvents and main() when making these
edits.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 22fb011f-888d-42f4-83c0-52611f4d84de
📒 Files selected for processing (1)
apps/web/scripts/misc/remove-self-referrals.ts
|
Ran the script, closing the PR now, thank you @devkiran! |
Summary by CodeRabbit