avniproject / avni-server

Backend APIs for Avni
https://avniproject.org
GNU Affero General Public License v3.0
7 stars 25 forks source link

Queries to fix duplicate privileges #746

Closed mahalakshme closed 2 months ago

mahalakshme commented 3 months ago

https://avni.freshdesk.com/a/tickets/4053

AC:

himeshr commented 2 months ago
  • Add query to update the version of all voided(independent of allow is true or false) to 0 and non-voided to 1

@mahalakshme Will not do this part as per discussion in Avni product group

mahalakshme commented 2 months ago

@himeshr no Joy mentioned so, because of AC for his card. It will all work together correctly

himeshr commented 2 months ago

@himeshr no Joy mentioned so, because of AC for his card. It will all work together correctly

~As per discussion, will update impl_version instead of earlier mentioned version column in group_privilege table.~

~Depends on #721 ~

himeshr commented 2 months ago

templateExpressionToGenerateUpdateScript.txt

Used this to auto-generate the sql script for all org-sheets mentioned in this card's description. update script sheet

1t5j0y commented 2 months ago

the manually run script (created via this card) should only update is_voided (and get the db to a valid state where we can apply the constraint). Updating impl_version also here creates a circular dependency.

the migration (in #721) will introduce the new impl_version column, mark all voided rows with impl_version 0 and add the constraint.

himeshr commented 2 months ago

the manually run script (created via this card) should only update is_voided (and get the db to a valid state where we can apply the constraint). Updating impl_version also here creates a circular dependency.

the migration (in #721) will introduce the new impl_version column, mark all voided rows with impl_version 0 and add the constraint.

Updated the script to not set the impl_version, and just retain 1 non-voided entry as part of the update script.

himeshr commented 2 months ago

Commands to find duplicate ids.txt WIP: query to void all duplicates after setting allow to false

himeshr commented 2 months ago

Local testing on pre-release for "Mobile Creches" org was successful, with following sql commands executed and output recieved. sqlOutputMobileCrechesRemovalOfDuplicatePrivileges.txt mobileCrechesRemovalOfDuplicatePrivileges.txt

petmongrels commented 2 months ago

For QA

mahalakshme commented 2 months ago

@himeshr

himeshr commented 2 months ago

Migration script available here

himeshr commented 2 months ago

Executed the group privileges updation script in production. ProdSqlsLogs.txt ProdSqlsExecuted.txt