remove accidentally left-in debugging output
[lhc/web/wiklou.git] / maintenance / tables.sql
1 -- SQL to create the initial tables for the Wikipedia database.
2 -- This is read and executed by the install script; you should
3 -- never have to run it by itself.
4 --
5 -- Indexes should be defined here; please import the rest from indexes.sql.
6
7 CREATE TABLE user (
8 user_id int(5) unsigned NOT NULL auto_increment,
9 user_name varchar(255) binary NOT NULL default '',
10 user_real_name varchar(255) binary NOT NULL default '',
11 user_rights tinyblob NOT NULL default '',
12 user_password tinyblob NOT NULL default '',
13 user_newpassword tinyblob NOT NULL default '',
14 user_email tinytext NOT NULL default '',
15 user_options blob NOT NULL default '',
16 user_touched char(14) binary NOT NULL default '',
17 UNIQUE KEY user_id (user_id)
18 ) PACK_KEYS=1;
19
20 CREATE TABLE user_newtalk (
21 user_id int(5) NOT NULL default '0',
22 user_ip varchar(40) NOT NULL default ''
23 );
24
25 CREATE TABLE cur (
26 cur_id int(8) unsigned NOT NULL auto_increment,
27 cur_namespace tinyint(2) unsigned NOT NULL default '0',
28 cur_title varchar(255) binary NOT NULL default '',
29 cur_text mediumtext NOT NULL default '',
30 cur_comment tinyblob NOT NULL default '',
31 cur_user int(5) unsigned NOT NULL default '0',
32 cur_user_text varchar(255) binary NOT NULL default '',
33 cur_timestamp char(14) binary NOT NULL default '',
34 cur_restrictions tinyblob NOT NULL default '',
35 cur_counter bigint(20) unsigned NOT NULL default '0',
36 cur_is_redirect tinyint(1) unsigned NOT NULL default '0',
37 cur_minor_edit tinyint(1) unsigned NOT NULL default '0',
38 cur_is_new tinyint(1) unsigned NOT NULL default '0',
39 cur_random real unsigned NOT NULL,
40 cur_touched char(14) binary NOT NULL default '',
41 inverse_timestamp char(14) binary NOT NULL default '',
42 UNIQUE KEY cur_id (cur_id)
43 ) PACK_KEYS=1;
44
45 CREATE TABLE old (
46 old_id int(8) unsigned NOT NULL auto_increment,
47 old_namespace tinyint(2) unsigned NOT NULL default '0',
48 old_title varchar(255) binary NOT NULL default '',
49 old_text mediumtext NOT NULL default '',
50 old_comment tinyblob NOT NULL default '',
51 old_user int(5) unsigned NOT NULL default '0',
52 old_user_text varchar(255) binary NOT NULL,
53 old_timestamp char(14) binary NOT NULL default '',
54 old_minor_edit tinyint(1) NOT NULL default '0',
55 old_flags tinyblob NOT NULL default '',
56 inverse_timestamp char(14) binary NOT NULL default '',
57 UNIQUE KEY old_id (old_id)
58 ) PACK_KEYS=1;
59
60 CREATE TABLE archive (
61 ar_namespace tinyint(2) unsigned NOT NULL default '0',
62 ar_title varchar(255) binary NOT NULL default '',
63 ar_text mediumtext NOT NULL default '',
64 ar_comment tinyblob NOT NULL default '',
65 ar_user int(5) unsigned NOT NULL default '0',
66 ar_user_text varchar(255) binary NOT NULL,
67 ar_timestamp char(14) binary NOT NULL default '',
68 ar_minor_edit tinyint(1) NOT NULL default '0',
69 ar_flags tinyblob NOT NULL default ''
70 ) PACK_KEYS=1;
71
72 --
73 -- Track links that do exist
74 -- l_from and l_to key to cur_id
75 --
76 CREATE TABLE links (
77 l_from int(8) unsigned NOT NULL default '0',
78 l_to int(8) unsigned NOT NULL default '0',
79 UNIQUE KEY l_from(l_from,l_to),
80 KEY (l_to)
81 );
82
83 --
84 -- Track links to pages that don't yet exist.
85 -- bl_from keys to cur_id
86 -- bl_to is a text link (namespace:title)
87 --
88 CREATE TABLE brokenlinks (
89 bl_from int(8) unsigned NOT NULL default '0',
90 bl_to varchar(255) binary NOT NULL default '',
91 UNIQUE KEY bl_from(bl_from,bl_to),
92 KEY (bl_to)
93 );
94
95 --
96 -- Track links to images *used inline*
97 -- il_from keys to cur_id, il_to keys to image_name.
98 -- We don't distinguish live from broken links.
99 --
100 CREATE TABLE imagelinks (
101 il_from int(8) unsigned NOT NULL default '0',
102 il_to varchar(255) binary NOT NULL default '',
103 UNIQUE KEY il_from(il_from,il_to),
104 KEY (il_to)
105 );
106
107 --
108 -- Track category inclusions *used inline*
109 -- cl_from keys to cur_id, cl_to keys to cur_title of the category page.
110 -- cl_sortkey is the title of the linking page or an optional override
111 -- cl_timestamp marks when the link was last added
112 --
113 CREATE TABLE categorylinks (
114 cl_from int(8) unsigned NOT NULL default '0',
115 cl_to varchar(255) binary NOT NULL default '',
116 cl_sortkey varchar(255) binary NOT NULL default '',
117 cl_timestamp timestamp NOT NULL,
118 UNIQUE KEY cl_from(cl_from,cl_to),
119 KEY cl_sortkey(cl_to,cl_sortkey(128)),
120 KEY cl_timestamp(cl_to,cl_timestamp)
121 );
122
123 --
124 -- Stores (possibly gzipped) serialized objects with
125 -- cache arrays to reduce database load slurping up
126 -- from links and brokenlinks.
127 --
128 CREATE TABLE linkscc (
129 lcc_pageid INT UNSIGNED NOT NULL UNIQUE KEY,
130 lcc_cacheobj MEDIUMBLOB NOT NULL
131 );
132
133 CREATE TABLE site_stats (
134 ss_row_id int(8) unsigned NOT NULL,
135 ss_total_views bigint(20) unsigned default '0',
136 ss_total_edits bigint(20) unsigned default '0',
137 ss_good_articles bigint(20) unsigned default '0',
138 UNIQUE KEY ss_row_id (ss_row_id)
139 );
140
141 CREATE TABLE hitcounter (
142 hc_id INTEGER UNSIGNED NOT NULL
143 ) TYPE=HEAP MAX_ROWS=25000;
144
145 CREATE TABLE ipblocks (
146 ipb_id int(8) NOT NULL auto_increment,
147 ipb_address varchar(40) binary NOT NULL default '',
148 ipb_user int(8) unsigned NOT NULL default '0',
149 ipb_by int(8) unsigned NOT NULL default '0',
150 ipb_reason tinyblob NOT NULL default '',
151 ipb_timestamp char(14) binary NOT NULL default '',
152 ipb_auto tinyint(1) NOT NULL default '0',
153 ipb_expiry char(14) binary NOT NULL default '',
154 UNIQUE KEY ipb_id (ipb_id)
155 ) PACK_KEYS=1;
156
157 CREATE TABLE image (
158 img_name varchar(255) binary NOT NULL default '',
159 img_size int(8) unsigned NOT NULL default '0',
160 img_description tinyblob NOT NULL default '',
161 img_user int(5) unsigned NOT NULL default '0',
162 img_user_text varchar(255) binary NOT NULL default '',
163 img_timestamp char(14) binary NOT NULL default '',
164 UNIQUE KEY img_name (img_name)
165 ) PACK_KEYS=1;
166
167 CREATE TABLE oldimage (
168 oi_name varchar(255) binary NOT NULL default '',
169 oi_archive_name varchar(255) binary NOT NULL default '',
170 oi_size int(8) unsigned NOT NULL default 0,
171 oi_description tinyblob NOT NULL default '',
172 oi_user int(5) unsigned NOT NULL default '0',
173 oi_user_text varchar(255) binary NOT NULL default '',
174 oi_timestamp char(14) binary NOT NULL default ''
175 ) PACK_KEYS=1;
176
177 CREATE TABLE recentchanges (
178 rc_id int(8) NOT NULL auto_increment,
179 rc_timestamp varchar(14) binary NOT NULL default '',
180 rc_cur_time varchar(14) binary NOT NULL default '',
181 rc_user int(10) unsigned NOT NULL default '0',
182 rc_user_text varchar(255) binary NOT NULL default '',
183 rc_namespace tinyint(3) unsigned NOT NULL default '0',
184 rc_title varchar(255) binary NOT NULL default '',
185 rc_comment varchar(255) binary NOT NULL default '',
186 rc_minor tinyint(3) unsigned NOT NULL default '0',
187 rc_bot tinyint(3) unsigned NOT NULL default '0',
188 rc_new tinyint(3) unsigned NOT NULL default '0',
189 rc_cur_id int(10) unsigned NOT NULL default '0',
190 rc_this_oldid int(10) unsigned NOT NULL default '0',
191 rc_last_oldid int(10) unsigned NOT NULL default '0',
192 rc_type tinyint(3) unsigned NOT NULL default '0',
193 rc_moved_to_ns tinyint(3) unsigned NOT NULL default '0',
194 rc_moved_to_title varchar(255) binary NOT NULL default '',
195 rc_patrolled tinyint(3) unsigned NOT NULL default '0',
196 rc_ip char(15) NOT NULL default '',
197 PRIMARY KEY rc_id (rc_id)
198 ) PACK_KEYS=1;
199
200 CREATE TABLE watchlist (
201 wl_user int(5) unsigned NOT NULL,
202 wl_namespace tinyint(2) unsigned NOT NULL default '0',
203 wl_title varchar(255) binary NOT NULL default '',
204 UNIQUE KEY (wl_user, wl_namespace, wl_title)
205 ) PACK_KEYS=1;
206
207 CREATE TABLE math (
208 math_inputhash varchar(16) NOT NULL,
209 math_outputhash varchar(16) NOT NULL,
210 math_html_conservativeness tinyint(1) NOT NULL,
211 math_html text,
212 math_mathml text,
213 UNIQUE KEY math_inputhash (math_inputhash)
214 );
215
216
217 -- Table searchindex must be MyISAM for fulltext support
218
219 CREATE TABLE searchindex (
220 si_page int(8) unsigned NOT NULL,
221 si_title varchar(255) NOT NULL default '',
222 si_text mediumtext NOT NULL default '',
223 UNIQUE KEY (si_page)
224 ) TYPE=MyISAM PACK_KEYS=1;
225
226 CREATE TABLE interwiki (
227 iw_prefix char(32) NOT NULL,
228 iw_url char(127) NOT NULL,
229 iw_local BOOL NOT NULL,
230 UNIQUE KEY iw_prefix (iw_prefix)
231 );
232
233 -- Used for caching expensive grouped queries
234 CREATE TABLE querycache (
235 qc_type char(32) NOT NULL,
236 qc_value int(5) unsigned NOT NULL default '0',
237 qc_namespace tinyint(2) unsigned NOT NULL default '0',
238 qc_title char(255) binary NOT NULL default '',
239 KEY (qc_type,qc_value)
240 );
241
242 -- For a few generic cache operations if not using Memcached
243 CREATE TABLE objectcache (
244 keyname char(255) binary not null default '',
245 value mediumblob,
246 exptime datetime,
247 unique key (keyname),
248 key (exptime)
249 );
250
251 -- For storing revision text
252 CREATE TABLE blobs (
253 blob_index char(255) binary NOT NULL default '',
254 blob_data longblob NOT NULL default '',
255 UNIQUE key blob_index (blob_index)
256 );
257
258 -- For article validation
259
260 CREATE TABLE `validate` (
261 `val_user` int(11) NOT NULL default '0',
262 `val_title` varchar(255) binary NOT NULL default '',
263 `val_timestamp` varchar(14) binary NOT NULL default '',
264 `val_type` int(10) unsigned NOT NULL default '0',
265 `val_value` int(11) default '0',
266 `val_comment` varchar(255) NOT NULL default '',
267 KEY `val_user` (`val_user`,`val_title`,`val_timestamp`)
268 ) TYPE=MyISAM;