4 -- Scrub the contents of the pgweb database, so the data can be reasonably shared
5 -- by updating and deleting anything sensitive
7 -- WARNING! DO NOT RUN IN PRODUCTION!
9 -- NOTE! BEFORE USE, ALWAYS VALIDATE THAT THE SCRIPT IS UP TO DATE!
12 -- Always runs as a transaction, just in case...
17 -- Commnity auth sites need reset crypto keys
18 -- The actual sites and id's are not secret.
19 UPDATE account_communityauthsite SET cryptkey='XXX';
21 -- Any outstanding email tokens need to just be removed
22 DELETE FROM account_emailchangetoken;
24 -- As this is the master database, we need to massage the user table since it has a lot
25 -- of sensitive data in it. We need to clear out names and emails, as well as passwords.
26 -- The user is expected to manually set up new users as needed, but we need these
27 -- links to remain in the system.
28 UPDATE auth_user SET username='id' || id,
31 email='e' || id || '@scrubbed.postgresql.org',
32 password='NOTAVALIDHASHSETBYSCRUBBINGSCRIPT',
33 is_staff='f', is_superuser='f';
35 UPDATE contributors_contributor SET email='e'||id||'@scrubbed.postgresql.org';
37 DELETE FROM core_moderationnotification;
39 UPDATE core_organisation SET email='e'||id||'@scrubbed.postgresql.org', phone='1-555-'||id,
40 name='O'||id, address='scrubbedaddress', url='http://scrubbed.url';
41 DELETE FROM core_organisation_managers;
42 UPDATE core_userprofile SET sshkey='SSHKEYSCRUBBED';
44 TRUNCATE TABLE django_admin_log;
45 TRUNCATE TABLE django_session;
47 -- Just in case we snapshotted with something in the queue
48 DELETE FROM mailqueue_queuedmail;
50 UPDATE profserv_professionalservice SET contact='scrubbedcontact';
52 TRUNCATE TABLE survey_surveylock;
54 -- We still have a lot of migration data, so lose it.
55 DROP TABLE IF EXISTS users_old;
56 DROP TABLE IF EXISTS docs_doccomment_saved;
58 \echo NOTE! Transaction has not been committed. Verify manually and then commit!