Closed 1t5j0y closed 1 day ago
This affects almost all orgs currently. Query to check impact:
with gp_counts as (select id, organisation_id, allow,
row_number()
over (partition by group_id, privilege_id, subject_type_id, program_id, program_encounter_type_id, encounter_type_id, checklist_detail_id order by id) as row_num
from group_privilege
where is_voided = false)
-- select * from gp_counts where row_num > 1;
select o.name, count(*) from gp_counts join organisation o on o.id = organisation_id where row_num > 1 group by o.name order by o.name ;
Queries in #746 to be executed (or alternate queries to remove dupes depending on environment) before deploying this.
Please add query to the release task if not added.
Issue:
AC:
Old: Ignore
Context:
Via #683 and maybe other routes, it is possible for duplicate non-voided group_privilege records for the same entity to be created in the database. This leads to confusing behaviour.
In https://avni.freshdesk.com/a/tickets/3760 we saw that there are duplicate records for a few entities, some with
allow
asfalse
and the other astrue
. On webapp user groups -> permissions screen, the true records were not shown. On client, since there is a record withallow
astrue
, the privilege is allowed and sync tries to pull entities that the user does not have privileges to and is causing association errors during sync.Further analysis might be required.