casa icon indicating copy to clipboard operation
casa copied to clipboard

Add a unique constraint for volunteer, langauge pairs in the join table

Open FireLemons opened this issue 2 years ago • 8 comments

Description Add a unique constraint for languages a volunteer can have

Screenshots of current behavior, if any
image As seen on the edit profile page for a volunteer

Login Emails:

password for all users: 12345678

Questions? Join Slack!

We highly recommend that you join us in slack https://rubyforgood.herokuapp.com/ #casa channel to ask questions quickly and hear about office hours (currently Tuesday 6-8pm Pacific), stakeholder news, and upcoming new issues.

FireLemons avatar Sep 20 '22 15:09 FireLemons

Hello! Can I work on this one?

andreLumor avatar Sep 20 '22 18:09 andreLumor

I sent you an invite for write permissions so you can claim your own issues

FireLemons avatar Sep 20 '22 19:09 FireLemons

Thanks for the invite! I'll gladly continue contributing to CASA!

andreLumor avatar Sep 20 '22 20:09 andreLumor

That was the wrong screenshot. I updated it

FireLemons avatar Sep 23 '22 03:09 FireLemons

Hey! I have some questions about how you would prefer I implement this issue.

The way it is implemented currently, we have multiple entries in the Language table with the same name, each belonging to different single users. This makes the has_and_belongs_to_many relation useless since even if a language can belong to 2 users, it isn't being used this way.

Proposed solution 1 (fewer changes in the database): Change the relation between user and language to "User has many Languages" and keep the repeated records of Language. This solution won't require any changes in the way languages are added to users right now, but will maintain unnecessary database usage

Proposed solution 2 (more database changes): Keep the has and belongs to many relation, remove repeated records, and change the way that languages are being added, from creating a new language every time to creating a new relation between User and Language.

Which implementation would you guys prefer?

andreLumor avatar Sep 27 '22 18:09 andreLumor

Oh I think you understood the problem based on the old screenshot. It's ok I'll just change the issue to match. We do want it to be unique for each user, language pair.

FireLemons avatar Sep 27 '22 20:09 FireLemons

I think we want a migration to remove any duplicates and then make language user combination in the languages_users table unique

FireLemons avatar Sep 27 '22 22:09 FireLemons

Hey, I'm not confident in my solution to this issue, worried that ill break something in the database. Is it ok if I unassign myself?

Thanks!

andreLumor avatar Oct 05 '22 19:10 andreLumor