dwyl / github-backup

:octocat: :back: 🆙 Backup your GitHub Issues so you can still work when (they/you are) offline.
https://github-backup.herokuapp.com
GNU General Public License v2.0
31 stars 3 forks source link

Add index + unique constraint on issue_id and comment_id #94

Open SimonLab opened 6 years ago

SimonLab commented 6 years ago

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.insertfunction on new install toRepo.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

nelsonic commented 6 years ago

This will certainly speed up queries. 🐎