Skip to content
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

Change notifications unique indexes #2525 #3012

Merged
merged 4 commits into from Jun 13, 2019

Conversation

lightalloy
Copy link
Contributor

@lightalloy lightalloy commented May 31, 2019

What type of PR is this? (check all applicable)

  • Bug Fix

Description

  • сhanged notifications indexes so that they take into account possible null values in user_id, organization_id, action fields
    Postgres allows to create records which contain the same fields if some of them contain null values, so I
    • created separate indexes for user_id and organization_id because notifications has either user_id or organization_id
    • made partial indexes for cases when action is null and when it's not null
  • added specs to check that notifications are not duplicated even when validations are skipped

Before merging, all the notifications that have duplicate fields %i[user_id organization_id notifiable_id notifiable_type action] must be deleted

Related Tickets & Documents

#2525

@lightalloy lightalloy changed the title [WIP] Change notifications unique indexes #2525 Change notifications unique indexes #2525 May 31, 2019
@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label May 31, 2019
@rhymes
Copy link
Contributor

rhymes commented Jun 6, 2019

Really good work @lightalloy ! I guess it needs to rebase or regenerate the schema.rb

Since we can't use foreign keys here, unique indexes are definitely of help!

@lightalloy
Copy link
Contributor Author

@rhymes thanks for reminding! I'll dot it.

Zhao-Andy
Zhao-Andy previously approved these changes Jun 7, 2019
Copy link
Contributor

@Zhao-Andy Zhao-Andy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks great! Going to reiterate your point before merging:

Before merging, all the notifications that have duplicate fields %i[user_id organization_id notifiable_id notifiable_type action] must be deleted.

@pr-triage pr-triage bot added PR: reviewed-approved bot applied label for PR's where reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Jun 7, 2019
@lightalloy lightalloy force-pushed the 2525-fix-notification-uniqueness branch from faa385b to ab40bcc Compare June 10, 2019 09:19
@pr-triage pr-triage bot added PR: unreviewed bot applied label for PR's with no review and removed PR: reviewed-approved bot applied label for PR's where reviewer approves changes labels Jun 10, 2019
Copy link
Contributor

@Zhao-Andy Zhao-Andy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving now that concurrent migrations are in place 👍

Before merging, all the notifications that have duplicate fields %i[user_id organization_id notifiable_id notifiable_type action] must be deleted.

@pr-triage pr-triage bot added PR: reviewed-approved bot applied label for PR's where reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Jun 13, 2019
@benhalpern benhalpern merged commit 2c05bbc into forem:master Jun 13, 2019
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: reviewed-approved bot applied label for PR's where reviewer approves changes labels Jun 13, 2019
@lightalloy lightalloy deleted the 2525-fix-notification-uniqueness branch June 14, 2019 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants