dwyl / dwyl/github-backup

Add index + unique constraint on issue_id and comment_id

Open
#94 1 comment 1 reaction 0 assignees View on GitHub
awaiting-review enhancement T25m
Dominant language
Elixir
Stars
33
Forks
3
PR merge metrics
No merged PRs in 30d

Description

The current schemas for `issue` and `comment` don't have any unique constraint and index on `issue_id` and `comment_id` yet.
This can be useful to make sure the data inserted are correct and to avoid duplicates.
A duplicate values can appear for example if the app is uninstalled and reinstalled again. As we won't automatically delete data in Postgres (see #87) this means that on the install we will save again all the issues and comments (see #65)
After adding these indexes and constraints we will need to update the Repo.insert` function on new install to `Repo.insert_or_update`:
https://github.com/dwyl/github-backup/blob/2960a82e0f2d89853d86380db4e5841677bbdbf3/lib/app_web/controllers/event_type_handlers.ex#L69

see https://hexdocs.pm/ecto/Ecto.Repo.html#c:insert_or_update/2

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.