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

Add index + unique constraint on issue_id and comment_id #94

Open
SimonLab opened this issue Mar 14, 2018 · 1 comment
Open

Add index + unique constraint on issue_id and comment_id #94

SimonLab opened this issue Mar 14, 2018 · 1 comment

Comments

@SimonLab
Copy link
Member

SimonLab commented Mar 14, 2018

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`:

issue = Repo.insert!(changeset)

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

@nelsonic
Copy link
Member

This will certainly speed up queries. 🐎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants