-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Remove duplicate org users #10198
Conversation
Add a constraint that forbids duplicate organization users. There is no need to have multiple entries as the join/leave events are already captured in OrganizationUserAudit.
When joining an organization, we want to reuse the OrganizationUser and reset all necessary fields.
.onConflict((oc) => | ||
oc.constraint('unique_org_user').doUpdateSet({ | ||
joinedAt: sql`CURRENT_TIMESTAMP`, | ||
removedAt: null, | ||
inactive: false, | ||
role: null, | ||
suggestedTier: null, | ||
tier: (eb) => eb.ref('excluded.tier') | ||
}) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm mostly concerned with this part. Previously we just created a new org user when a new user joined, but now we have to reset all the old fields that should be reset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! i don't think we use trialStartDate anymore so we can ignore that column.
Description
Fixes #9302
Add a constraint that forbids duplicate organization users. There is no need to have multiple entries as the join/leave events are already captured in OrganizationUserAudit.
Demo
[If possible, please include a screenshot or gif/video, it'll make it easier for reviewers to understand the scope of the changes and how the change is supposed to work. If you're introducing something new or changing the existing patterns, please share a Loom and explain what decisions you've made and under what circumstances]
Testing scenarios
Final checklist