Skip to content

Commit 94e72e4

Browse files
committed
🕵 Add script to remove PII from database
1 parent 2d4ef46 commit 94e72e4

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

scripts/remove-pii.sql

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
delete
2+
from book_lists
3+
where type = 'PERSONAL';
4+
5+
delete
6+
from class_groups;
7+
8+
delete
9+
from collection_item_activity_log;
10+
11+
delete
12+
from collections
13+
where user_id is not null;
14+
15+
refresh materialized view work_collection_frequency;
16+
17+
delete
18+
from educators;
19+
delete
20+
from readers;
21+
delete
22+
from public_readers;
23+
delete
24+
from parents;
25+
delete
26+
from school_admins;
27+
delete
28+
from students;
29+
delete
30+
from supporters;
31+
delete
32+
from wriveted_admins;
33+
34+
delete
35+
from events;
36+
delete
37+
from users;
38+
delete
39+
from subscriptions;
40+
41+
delete
42+
from supporter_reader_association;
43+
44+
DELETE
45+
FROM labelset_reading_ability_association
46+
WHERE labelset_id IN (SELECT id FROM labelsets WHERE summary_origin = 'PREDICTED_NIELSEN');
47+
48+
delete
49+
from labelsets
50+
where summary_origin = 'PREDICTED_NIELSEN';
51+
52+
delete FROM collections
53+
where id in (
54+
select c.id from collections c LEFT JOIN collection_items ci ON c.id = ci.collection_id
55+
WHERE ci.id IS NULL);

0 commit comments

Comments
 (0)