Fix duplicate invites #1437

Merged
tonyvince merged 2 commits from fix-1436 into main 2024-11-08 23:58:35 +08:00
tonyvince commented 2024-11-08 23:52:17 +08:00 (Migrated from github.com)

Fix #1436

Fix #1436
Shpigford commented 2024-11-08 23:58:27 +08:00 (Migrated from github.com)

This pull request introduces a new validation to ensure that an email can only be invited once per family and adds a unique index to enforce this constraint at the database level. The most important changes include updating the Invitation model and modifying the database schema to include the new unique index.

Model validation updates:

Database schema updates:

This pull request introduces a new validation to ensure that an email can only be invited once per family and adds a unique index to enforce this constraint at the database level. The most important changes include updating the `Invitation` model and modifying the database schema to include the new unique index. ### Model validation updates: * [`app/models/invitation.rb`](diffhunk://#diff-c899291de1875b0c2483c0f132ed4503e6c33be63148d6e5d1f4235bfeb1c331R8): Added a validation to ensure the uniqueness of the `email` within the scope of `family_id`. ### Database schema updates: * [`db/migrate/20241108150422_add_unique_email_index_to_invitations.rb`](diffhunk://#diff-01e56a02a0bba547e0fe2ca3c6b1b1655805acdc85d4e701f79bbeb8f2ae7ba8R1-R5): Created a migration to add a unique index on the `email` and `family_id` columns in the `invitations` table. * [`db/schema.rb`](diffhunk://#diff-cbf8b25d6d853acf58fa9057841f407d29ffe90649c75cf9e3f51b2d6e3aa1d3L13-R13): Updated the schema to reflect the new unique index on the `email` and `family_id` columns in the `invitations` table. [[1]](diffhunk://#diff-cbf8b25d6d853acf58fa9057841f407d29ffe90649c75cf9e3f51b2d6e3aa1d3L13-R13) [[2]](diffhunk://#diff-cbf8b25d6d853acf58fa9057841f407d29ffe90649c75cf9e3f51b2d6e3aa1d3R430)
Shpigford commented 2024-11-08 23:58:42 +08:00 (Migrated from github.com)

Thanks @tonyvince!

Thanks @tonyvince!
Sign in to join this conversation.