forked from Drupalcz/drupalcz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slim.sql
183 lines (173 loc) · 4.71 KB
/
slim.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Will remove most of the content to make DB smaller.
# CONSEQUENCES:
# Result includes these content types:
# story
# blog
# forum
# content_katalog
# faq
# bezpecnost
# content_webhosting
# poll
# lecture
# Result does NOT include these content types:
# company
# katalog
# page
# Delete some users.
DELETE FROM users WHERE uid > '100';
DELETE FROM profile_values WHERE uid > '100';
DELETE FROM authmap WHERE uid > '100';
DELETE FROM history WHERE uid > '100';
# Nodes.
DELETE FROM node WHERE uid NOT IN (
SELECT uid FROM users AS uid
);
# Make forum even smaller.
DELETE FROM node WHERE type = 'forum' AND uid = '0' AND nid < '5000';
# Node revisions.
DELETE FROM node_revisions WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
# Fields.
DELETE FROM content_field_download WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_field_gallery_image WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_field_popis_webu WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_field_screenshoty WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_field_staen WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_field_url WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_field_url_multiple WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
# Fields.
DELETE FROM content_type_ad WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_advpoll_binary WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_advpoll_ranking WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_banner WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_bezpecnost WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_book WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_company WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_content_katalog WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_content_webhosting WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_forum WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_gallery WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_image WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_katalog WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_lecture WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_page WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_poll WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
DELETE FROM content_type_story WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
# Forum.
DELETE FROM forum WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
# Delete comments of deleted users.
## And prevent "Lock wait timeout exceeded".
DELETE FROM comments WHERE uid > '4000';
DELETE FROM comments WHERE uid > '3000';
DELETE FROM comments WHERE uid > '2000';
DELETE FROM comments WHERE uid > '1000';
DELETE FROM comments WHERE uid > '100';
# Delete comments on deleted notes.
DELETE FROM comments WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
# Delete most of anonymous comments.
DELETE FROM comments WHERE uid = '0' AND cid > '1000';
# Delete comments that are replies to deleted comments.
DROP PROCEDURE IF EXISTS fix_cmmnts;
delimiter //
CREATE PROCEDURE fix_cmmnts ()
BEGIN
DECLARE max int default 18;
DECLARE i int default 0;
start transaction;
while i < max do
DELETE FROM comments WHERE pid !=0 AND pid NOT IN (
SELECT * FROM (
SELECT cid FROM comments
) AS cid
);
set i = i + 1;
end while;
commit;
END//
delimiter ;
CALL fix_cmmnts();
# Location instance.
DELETE FROM location_instance WHERE lid IN (
SELECT * FROM (
SELECT location_instance.lid FROM location_instance JOIN location ON location_instance.lid=location.lid WHERE location_instance.uid > '100'
) AS lid
);
# Location.
DELETE FROM location WHERE lid NOT IN (
SELECT lid FROM location_instance AS lid
);
# Poll votes.
DELETE FROM poll_votes WHERE nid NOT IN (
SELECT nid FROM node AS nid
);
# No impact on migration, just making the DB smaller.
TRUNCATE TABLE ads;
TRUNCATE TABLE ad_clicks;
TRUNCATE TABLE ad_owners;
TRUNCATE TABLE ad_statistics;
TRUNCATE TABLE aggregator_category_item;
TRUNCATE TABLE aggregator_feed;
TRUNCATE TABLE aggregator_item;
TRUNCATE TABLE aggregator_category_item;
TRUNCATE TABLE locales_source;
TRUNCATE TABLE locales_target;
TRUNCATE TABLE search_dataset;
TRUNCATE TABLE search_index;
TRUNCATE TABLE search_node_links;
TRUNCATE TABLE search_total;
TRUNCATE TABLE spam_tracker;
TRUNCATE TABLE url_alias;