sanitize-db-wwc.sql 1.67 KB
Newer Older
1 2 3
SET FOREIGN_KEY_CHECKS=0;

/*
4 5 6
  Remove all password hashes, even for edx employees
*/

7
UPDATE auth_user
8 9 10
    set
        password = null;

11
UPDATE student_passwordhistory
12 13 14 15
    set
        password = null;

/*
16
  Rewrite all emails to used the SES simulator, simulating success.
17
  Anonymize other user information. Skip @edx.org accounts
18 19
*/

20
UPDATE auth_user
John Jarvis committed
21 22 23 24 25 26 27 28
    set 
        email = concat('success+',cast(id AS CHAR),'@simulator.amazonses.com'),
        username = concat('user-',cast(id AS CHAR)),
        first_name = concat('user-',cast(id AS CHAR)),
        last_name = concat('user-',cast(id AS CHAR)),
        last_login = null,
        date_joined = null
            where email not like ('%@edx.org');
29 30 31 32 33

/*
   There are a handful of email changes requests captured in flight.
*/

34
UPDATE student_pendingemailchange
35 36 37 38 39 40 41 42
    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.
*/

43
UPDATE student_courseenrollmentallowed
44 45 46 47 48 49 50
    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
*/

51
UPDATE auth_userprofile
John Jarvis committed
52 53 54 55 56 57 58 59 60 61 62 63
    set 
        name = concat('user-',cast(id as CHAR)),
        language = "",
        location = "",
        meta = "",
        gender = null,
        mailing_address = null,
        year_of_birth = null,
        level_of_education = null,
        goals = null,
        country = "",
        city = null;
64 65

SET FOREIGN_KEY_CHECKS=1;