Some changes to the link tables. They now all use a key on cur_id for the *_from...
[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 DROP TABLE IF EXISTS user;
8 CREATE TABLE user (
9 user_id int(5) unsigned NOT NULL auto_increment,
10 user_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 DROP TABLE IF EXISTS user_newtalk;
21 CREATE TABLE user_newtalk (
22 user_id int(5) NOT NULL default '0',
23 user_ip varchar(40) NOT NULL default ''
24 );
25
26 DROP TABLE IF EXISTS cur;
27 CREATE TABLE cur (
28 cur_id int(8) unsigned NOT NULL auto_increment,
29 cur_namespace tinyint(2) unsigned NOT NULL default '0',
30 cur_title varchar(255) binary NOT NULL default '',
31 cur_text mediumtext NOT NULL default '',
32 cur_comment tinyblob NOT NULL default '',
33 cur_user int(5) unsigned NOT NULL default '0',
34 cur_user_text varchar(255) binary NOT NULL default '',
35 cur_timestamp char(14) binary NOT NULL default '',
36 cur_restrictions tinyblob NOT NULL default '',
37 cur_counter bigint(20) unsigned NOT NULL default '0',
38 cur_is_redirect tinyint(1) unsigned NOT NULL default '0',
39 cur_minor_edit tinyint(1) unsigned NOT NULL default '0',
40 cur_is_new tinyint(1) unsigned NOT NULL default '0',
41 cur_random real unsigned NOT NULL,
42 cur_touched char(14) binary NOT NULL default '',
43 inverse_timestamp char(14) binary NOT NULL default '',
44 UNIQUE KEY cur_id (cur_id)
45 ) PACK_KEYS=1;
46
47 DROP TABLE IF EXISTS old;
48 CREATE TABLE old (
49 old_id int(8) unsigned NOT NULL auto_increment,
50 old_namespace tinyint(2) unsigned NOT NULL default '0',
51 old_title varchar(255) binary NOT NULL default '',
52 old_text mediumtext NOT NULL default '',
53 old_comment tinyblob NOT NULL default '',
54 old_user int(5) unsigned NOT NULL default '0',
55 old_user_text varchar(255) binary NOT NULL,
56 old_timestamp char(14) binary NOT NULL default '',
57 old_minor_edit tinyint(1) NOT NULL default '0',
58 old_flags tinyblob NOT NULL default '',
59 inverse_timestamp char(14) binary NOT NULL default '',
60 UNIQUE KEY old_id (old_id)
61 ) PACK_KEYS=1;
62
63 DROP TABLE IF EXISTS archive;
64 CREATE TABLE archive (
65 ar_namespace tinyint(2) unsigned NOT NULL default '0',
66 ar_title varchar(255) binary NOT NULL default '',
67 ar_text mediumtext NOT NULL default '',
68 ar_comment tinyblob NOT NULL default '',
69 ar_user int(5) unsigned NOT NULL default '0',
70 ar_user_text varchar(255) binary NOT NULL,
71 ar_timestamp char(14) binary NOT NULL default '',
72 ar_minor_edit tinyint(1) NOT NULL default '0',
73 ar_flags tinyblob NOT NULL default ''
74 ) PACK_KEYS=1;
75
76 --
77 -- Track links that do exist
78 -- l_from and l_to key to cur_id
79 --
80 DROP TABLE IF EXISTS links;
81 CREATE TABLE links (
82 l_from int(8) unsigned NOT NULL default '0',
83 l_to int(8) unsigned NOT NULL default '0',
84 UNIQUE KEY l_from(l_from,l_to),
85 KEY (l_to)
86 );
87
88 --
89 -- Track links to pages that don't yet exist.
90 -- bl_from keys to cur_id
91 -- bl_to is a text link (namespace:title)
92 --
93 DROP TABLE IF EXISTS brokenlinks;
94 CREATE TABLE brokenlinks (
95 bl_from int(8) unsigned NOT NULL default '0',
96 bl_to varchar(255) binary NOT NULL default '',
97 UNIQUE KEY bl_from(bl_from,bl_to),
98 KEY (bl_to)
99 );
100
101 --
102 -- Track links to images *used inline*
103 -- il_from keys to cur_id, il_to keys to image_name.
104 -- We don't distinguish live from broken links.
105 --
106 DROP TABLE IF EXISTS imagelinks;
107 CREATE TABLE imagelinks (
108 il_from int(8) unsigned NOT NULL default '0',
109 il_to varchar(255) binary NOT NULL default '',
110 UNIQUE KEY il_from(il_from,il_to),
111 KEY (il_to)
112 );
113
114 --
115 -- Stores (possibly gzipped) serialized objects with
116 -- cache arrays to reduce database load slurping up
117 -- from links and brokenlinks.
118 --
119 DROP TABLE IF EXISTS linkscc;
120 CREATE TABLE linkscc (
121 lcc_pageid INT UNSIGNED NOT NULL UNIQUE KEY,
122 lcc_cacheobj MEDIUMBLOB NOT NULL
123 );
124
125 DROP TABLE IF EXISTS site_stats;
126 CREATE TABLE site_stats (
127 ss_row_id int(8) unsigned NOT NULL,
128 ss_total_views bigint(20) unsigned default '0',
129 ss_total_edits bigint(20) unsigned default '0',
130 ss_good_articles bigint(20) unsigned default '0',
131 UNIQUE KEY ss_row_id (ss_row_id)
132 );
133
134 DROP TABLE IF EXISTS hitcounter;
135 CREATE TABLE hitcounter (
136 hc_id INTEGER UNSIGNED NOT NULL
137 ) TYPE=HEAP MAX_ROWS=25000;
138
139 DROP TABLE IF EXISTS ipblocks;
140 CREATE TABLE ipblocks (
141 ipb_id int(8) NOT NULL auto_increment,
142 ipb_address varchar(40) binary NOT NULL default '',
143 ipb_user int(8) unsigned NOT NULL default '0',
144 ipb_by int(8) unsigned NOT NULL default '0',
145 ipb_reason tinyblob NOT NULL default '',
146 ipb_timestamp char(14) binary NOT NULL default '',
147 ipb_auto tinyint(1) NOT NULL default '0',
148 ipb_expiry char(14) binary NOT NULL default '',
149 UNIQUE KEY ipb_id (ipb_id)
150 ) PACK_KEYS=1;
151
152 DROP TABLE IF EXISTS image;
153 CREATE TABLE image (
154 img_name varchar(255) binary NOT NULL default '',
155 img_size int(8) unsigned NOT NULL default '0',
156 img_description tinyblob NOT NULL default '',
157 img_user int(5) unsigned NOT NULL default '0',
158 img_user_text varchar(255) binary NOT NULL default '',
159 img_timestamp char(14) binary NOT NULL default ''
160 ) PACK_KEYS=1;
161
162 DROP TABLE IF EXISTS oldimage;
163 CREATE TABLE oldimage (
164 oi_name varchar(255) binary NOT NULL default '',
165 oi_archive_name varchar(255) binary NOT NULL default '',
166 oi_size int(8) unsigned NOT NULL default 0,
167 oi_description tinyblob NOT NULL default '',
168 oi_user int(5) unsigned NOT NULL default '0',
169 oi_user_text varchar(255) binary NOT NULL default '',
170 oi_timestamp char(14) binary NOT NULL default ''
171 ) PACK_KEYS=1;
172
173 DROP TABLE IF EXISTS recentchanges;
174 CREATE TABLE recentchanges (
175 rc_timestamp varchar(14) binary NOT NULL default '',
176 rc_cur_time varchar(14) binary NOT NULL default '',
177 rc_user int(10) unsigned NOT NULL default '0',
178 rc_user_text varchar(255) binary NOT NULL default '',
179 rc_namespace tinyint(3) unsigned NOT NULL default '0',
180 rc_title varchar(255) binary NOT NULL default '',
181 rc_comment varchar(255) binary NOT NULL default '',
182 rc_minor tinyint(3) unsigned NOT NULL default '0',
183 rc_bot tinyint(3) unsigned NOT NULL default '0',
184 rc_new tinyint(3) unsigned NOT NULL default '0',
185 rc_cur_id int(10) unsigned NOT NULL default '0',
186 rc_this_oldid int(10) unsigned NOT NULL default '0',
187 rc_last_oldid int(10) unsigned NOT NULL default '0',
188 rc_type tinyint(3) unsigned NOT NULL default '0',
189 rc_moved_to_ns tinyint(3) unsigned NOT NULL default '0',
190 rc_moved_to_title varchar(255) binary NOT NULL default ''
191 ) PACK_KEYS=1;
192
193 DROP TABLE IF EXISTS watchlist;
194 CREATE TABLE watchlist (
195 wl_user int(5) unsigned NOT NULL,
196 wl_namespace tinyint(2) unsigned NOT NULL default '0',
197 wl_title varchar(255) binary NOT NULL default '',
198 UNIQUE KEY (wl_user, wl_namespace, wl_title)
199 ) PACK_KEYS=1;
200
201 DROP TABLE IF EXISTS math;
202 CREATE TABLE math (
203 math_inputhash varchar(16) NOT NULL,
204 math_outputhash varchar(16) NOT NULL,
205 math_html_conservativeness tinyint(1) NOT NULL,
206 math_html text,
207 math_mathml text,
208 UNIQUE KEY math_inputhash (math_inputhash)
209 );
210
211
212 -- Table searchindex must be MyISAM for fulltext support
213
214 DROP TABLE IF EXISTS searchindex;
215 CREATE TABLE searchindex (
216 si_page int(8) unsigned NOT NULL,
217 si_title varchar(255) NOT NULL default '',
218 si_text mediumtext NOT NULL default '',
219 UNIQUE KEY (si_page)
220 ) PACK_KEYS=1;
221
222 DROP TABLE IF EXISTS interwiki;
223 CREATE TABLE interwiki (
224 iw_prefix char(32) NOT NULL,
225 iw_url char(127) NOT NULL,
226 iw_local BOOL NOT NULL,
227 UNIQUE KEY iw_prefix (iw_prefix)
228 );
229