Currently there are duplicate group privileges, such that for the same entities allow is true as well as false.
Root causes:
In the migration to insert group_privileges we have used uuid_generate_v4() and in the bundle import we are again identifying a group_privilege by uuid resulting in duplicates in prod orgs.
This migration can result in duplicate privileges since there are duplicate form mappings in the db.
The same can be easily found. Eg: group_privileges with UUIDs - 7ace876e-8135-445b-9ded-da0918561b8f, 3046821d-d1ce-4c73-98eb-14b11256a4d2.
This migration is incorrect and will not update duplicates with is_voided as true since update of multiple columns need to be separated by , and not AND
Step 1: For all the active organisations identify the right group privilege value and update the last_modified_date_time
Step 2: Void the duplicate privileges(with conflicting as well as same value) and update the audit fields for them
Step 3: Update version to 0 for all voided, and version to 1 for all non-voided. This is to be able to bundle import voided fields when need arises in the future, by having only one entry in db for each combination.
Step 4: Add constraint in db to maintain unique group privilege for a combination of entities(encounter type, privilege, subject type, etc.,), voided, like form_mappings(here impl., version) only for unvoided
Step 5: In bundle upload identify a group privilege entry using the unique combination of entries and not by uuid to prevent such issues from migrations in future.
Step 6: To fix duplicates in mobile app, Sync voided field also for group privileges to mobile app - which means will get fixed only after mobile upgrade which is fine.
Step 7: Whenever checking for privileges in mobile app, check for only unvoided.
Issue:
Currently there are duplicate group privileges, such that for the same entities allow is true as well as false.
Root causes:
uuid_generate_v4()
and in the bundle import we are again identifying a group_privilege by uuid resulting in duplicates in prod orgs.,
and notAND
Solution:
Step 1: For all the active organisations identify the right group privilege value and update the last_modified_date_time Step 2: Void the duplicate privileges(with conflicting as well as same value) and update the audit fields for them Step 3: Update version to 0 for all voided, and version to 1 for all non-voided. This is to be able to bundle import voided fields when need arises in the future, by having only one entry in db for each combination. Step 4: Add constraint in db to maintain unique group privilege for a combination of entities(encounter type, privilege, subject type, etc.,), voided, like form_mappings(here impl., version) only for unvoided Step 5: In bundle upload identify a group privilege entry using the unique combination of entries and not by uuid to prevent such issues from migrations in future. Step 6: To fix duplicates in mobile app, Sync voided field also for group privileges to mobile app - which means will get fixed only after mobile upgrade which is fine. Step 7: Whenever checking for privileges in mobile app, check for only unvoided.
Inputs: