avniproject / avni-product

https://avniproject.org/
7 stars 9 forks source link

Privileges issue fix #1608

Closed mahalakshme closed 1 month ago

mahalakshme commented 4 months ago

Issue:

Currently there are duplicate group privileges, such that for the same entities allow is true as well as false.

Root causes:

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.

### Tasks
- [ ] https://github.com/avniproject/avni-server/issues/746
- [ ] https://github.com/avniproject/avni-server/issues/721
- [ ] https://github.com/avniproject/avni-client/issues/1459

Inputs: