Skip to content

dont use repo_id as part of the natural key for a pull request - #480

Draft
MoralCode wants to merge 1 commit into
mainfrom
ntdn/natural_keys_pr2
Draft

MoralCode wants to merge 1 commit into
mainfrom
ntdn/natural_keys_pr2

Conversation

@MoralCode

Copy link
Copy Markdown
Contributor

Description
This removes the repo_id from the list of natural keys passed to insert_data when processing pull requests.

This prevents augur from trying to insert duplicate PRs from github on older instances where PRs may have been manually merged following the resolution of duplicate repos (i.e. two different repo_ids pointed to the same repo because that repo renamed itself). If repo_ids are not updated EVERYWHERE, this may cause augur to try and insert under the new, merged repo ID, and not detect that a duplicate value exists in the DB already. Therefore this would cause postgres to yell at augur because of an attempt to insert a PR with a duplicate URL.

Because we have strong reason to assume the pr_src_id from github is unique, we can rely solely on this as the check for duplicate information.

This PR fixes #93

I notice the same issue exists in the gitlab code too.

This PR is arguably technically incomplete without also updating the unique constraints on the pull_requests table to also enforce uniqueness based ONLY on the pr_src_id. However, if a DB isn't perfectly deduplicated, the migration to this could cause some issues.

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

Signed-off-by: Adrian Edwards <17362949+MoralCode@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collect_pull_requests : IntegrityError('(psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "pull-request-insert-unique"

1 participant