This repository has been archived by the owner on May 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 971
adding an sql script for sanitizing the prod mysql db #1052
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
248f37e
adding an sql script for sanitizing the prod mysql db
jarv 8aabc33
setting pass to an empty string, removing truncate
jarv 3b73d98
pass back to null
jarv 69e3717
syntax
jarv 0f11d60
syntax
jarv 2a7669b
adding student_passwordhistory
jarv 5671dfb
adding logic to clean the cloned db
jarv 74fb2c2
removing python-msql task
jarv e512b5f
running update db users locally
jarv 6bf8d39
fixing help for security-group
jarv 360e571
updating boto
jarv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
SET FOREIGN_KEY_CHECKS=0; | ||
|
||
/* | ||
Truncate the courseware_studentmodulehistory table since | ||
it is only needed for analytics | ||
*/ | ||
|
||
TRUNCATE courseware_studentmodulehistory; | ||
|
||
/* | ||
Rewrite all emails to used the SES simulator, simulating success. | ||
Anonymize other user information | ||
*/ | ||
|
||
UPDATE wwc.auth_user | ||
set email = concat('success+',cast(id AS CHAR),'@simulator.amazonses.com') | ||
where email not like ('%@edx.org'), | ||
set username = concat('user-',cast(id AS CHAR) | ||
where email not like ('%@edx.org'), | ||
set first_name = concat('user-',cast(id AS CHAR) | ||
where email not like ('%@edx.org'), | ||
set last_name = concat('user-',cast(id AS CHAR) | ||
where email not like ('%@edx.org'), | ||
set password = null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little surprised this is nullable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's the default, maybe set it to an empty string instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's nullable, I'm fine with this; I'm just surprised. |
||
where email not like ('%@edx.org'), | ||
set last_login = null | ||
where email not like ('%@edx.org'), | ||
set date_joined = null | ||
where email not like ('%@edx.org'); | ||
|
||
/* | ||
There are a handful of email changes requests captured in flight. | ||
*/ | ||
|
||
UPDATE wwc.student_pendingemailchange | ||
set new_email = concat('success+',cast(user_id AS CHAR),'@simulator.amazonses.com'); | ||
|
||
/* | ||
Differs slightly to prevent creating duplicate email records. | ||
User id isn't stored here and this email is probably not used for | ||
sending email, but cannot hurt. | ||
*/ | ||
|
||
UPDATE wwc.student_courseenrollmentallowed | ||
set email = concat('success+','courseenrollmentallowed_',cast(id AS CHAR),'@simulator.amazonses.com'); | ||
|
||
/* | ||
Set the name to the userid and empty the other fields | ||
This will also empty user profile data for edx employees | ||
*/ | ||
|
||
UPDATE wwc.auth_userprofile | ||
set name = concat('user-',cast(id as CHAR)), | ||
set language = "", | ||
set location = "", | ||
set meta = "", | ||
set gender = null, | ||
set mailing_address = null, | ||
set year_of_birth = null, | ||
set level_of_education = null, | ||
set goals = null | ||
set country = "", | ||
set city = null; | ||
|
||
/* | ||
Grader has its own django core tables. | ||
*/ | ||
|
||
UPDATE prod_grader.auth_user | ||
set email = concat('success+',cast(id AS CHAR),'@simulator.amazonses.com') | ||
where email not like ('%@edx.org'), | ||
set username = concat('user-',cast(id AS CHAR) | ||
where email not like ('%@edx.org'), | ||
set first_name = concat('user-',cast(id AS CHAR) | ||
where email not like ('%@edx.org'), | ||
set last_name = concat('user-',cast(id AS CHAR) | ||
where email not like ('%@edx.org'), | ||
set password = null | ||
where email not like ('%@edx.org'), | ||
set last_login = null | ||
where email not like ('%@edx.org'), | ||
set date_joined = null | ||
where email not like ('%@edx.org'); | ||
|
||
|
||
SET FOREIGN_KEY_CHECKS=1; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably put some conditional logic around this in case we handle leaving this out upstream, say by using manual export commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's not part of the sanitation I'll remove it and run the truncate separately.