Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queries to fix duplicate privileges #746

Closed
Tracked by #1608
mahalakshme opened this issue Jul 8, 2024 · 12 comments
Closed
Tracked by #1608

Queries to fix duplicate privileges #746

mahalakshme opened this issue Jul 8, 2024 · 12 comments
Assignees
Labels

Comments

@mahalakshme
Copy link
Contributor

mahalakshme commented Jul 8, 2024

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

AC:

  • For Mobile Creches and Shelter here - encounter type, not included(include it). Update last_modified_by_user_id to your super_admin. And review other queries if they are fine.
  • Across all orgs, wherever there is duplicate group_privilege which are not voided and have same values for "allow",
    • make an update to void all except one,
    • for each of the entries to be voided, update the last_modified_date and last_modified_by_id and set "allow" to false
  • Add query to void all the duplicates and also set the "allow" field to "False" always for all voided groupPrivilges [ Note: Change as per details specified here]
  • Add query to update the impl_version of all voided(independent of allow is true or false) to 0 and non-voided to 1
@mahalakshme mahalakshme converted this from a draft issue Jul 8, 2024
@mahalakshme mahalakshme moved this from In Analysis to In Analysis Review in Avni Product Jul 8, 2024
@mahalakshme mahalakshme moved this from In Analysis Review to Ready in Avni Product Jul 9, 2024
@himeshr himeshr self-assigned this Jul 9, 2024
@himeshr himeshr moved this from Ready to In Progress in Avni Product Jul 9, 2024
@1t5j0y 1t5j0y changed the title Queries to fix the duplicates Queries to fix duplicate privileges Jul 9, 2024
@himeshr
Copy link
Contributor

himeshr commented Jul 9, 2024

  • 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
Copy link
Contributor Author

mahalakshme commented Jul 9, 2024

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

@himeshr
Copy link
Contributor

himeshr commented Jul 9, 2024

@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
Copy link
Contributor

himeshr commented Jul 9, 2024

templateExpressionToGenerateUpdateScript.txt

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

@himeshr himeshr moved this from In Progress to Code Review Ready in Avni Product Jul 9, 2024
@1t5j0y
Copy link
Contributor

1t5j0y commented Jul 9, 2024

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
Copy link
Contributor

himeshr commented Jul 9, 2024

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.

@mahalakshme mahalakshme moved this from Code Review Ready to In Code Review in Avni Product Jul 10, 2024
@mahalakshme mahalakshme moved this from In Code Review to Code Review Ready in Avni Product Jul 10, 2024
@himeshr himeshr moved this from Code Review Ready to In Progress in Avni Product Jul 10, 2024
@himeshr
Copy link
Contributor

himeshr commented Jul 10, 2024

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

@himeshr
Copy link
Contributor

himeshr commented Jul 11, 2024

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

@himeshr himeshr moved this from In Progress to Code Review Ready in Avni Product Jul 11, 2024
@petmongrels petmongrels moved this from Code Review Ready to In Code Review in Avni Product Jul 12, 2024
@mahalakshme mahalakshme moved this from In Code Review to Code Review with Comments in Avni Product Jul 15, 2024
@petmongrels
Copy link
Contributor

For QA

  • the scripts will need to be run on production
  • testing and verification should be done in prerelease environment. When verifying we should verify whether the privileges for users are same as they are in production. This is required because the privileges will get updated when the deployment is done for this.
  • It would be good to refresh pre-release before testing this (we should make sure that the downtime doesn't block other people)

@petmongrels petmongrels moved this from Code Review with Comments to QA Ready in Avni Product Jul 15, 2024
@mahalakshme mahalakshme moved this from QA Ready to Code Review with Comments in Avni Product Jul 16, 2024
@himeshr himeshr moved this from Code Review with Comments to Code Review Ready in Avni Product Jul 16, 2024
@mahalakshme mahalakshme moved this from Code Review Ready to In Code Review in Avni Product Jul 16, 2024
@mahalakshme
Copy link
Contributor Author

mahalakshme commented Jul 16, 2024

@himeshr

  • check this comment
  • I have updated the privileges with discrepancies for all active organisations here in the sheet: 'For all active orgs with discrepancies'.
  • The privileges with discrepancies have changed. So I have used the same formula in the above sheet.
  • In the 'Active orgs' sheet have added the final list of active orgs that have discrepancies.

@mahalakshme mahalakshme moved this from In Code Review to QA Ready in Avni Product Jul 16, 2024
@mahalakshme mahalakshme moved this from QA Ready to Code Review with Comments in Avni Product Jul 16, 2024
@himeshr himeshr moved this from Code Review with Comments to QA Ready in Avni Product Jul 17, 2024
@himeshr himeshr moved this from QA Ready to In QA in Avni Product Jul 17, 2024
@himeshr himeshr moved this from In QA to Further Action Required in Avni Product Jul 17, 2024
@himeshr himeshr moved this from Further Action Required to Code Review Ready in Avni Product Jul 18, 2024
@himeshr
Copy link
Contributor

himeshr commented Jul 18, 2024

Migration script available here

@mahalakshme mahalakshme moved this from Code Review Ready to In Code Review in Avni Product Jul 18, 2024
@mahalakshme mahalakshme moved this from In Code Review to Code Review with Comments in Avni Product Jul 18, 2024
@mahalakshme mahalakshme moved this from Code Review with Comments to In Code Review in Avni Product Jul 18, 2024
@mahalakshme mahalakshme moved this from In Code Review to QA Ready in Avni Product Jul 19, 2024
@himeshr
Copy link
Contributor

himeshr commented Jul 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

4 participants