Index: trunk/phase3/maintenance/postgres/tables.sql |
— | — | @@ -18,9 +18,9 @@ |
19 | 19 | user_password TEXT, |
20 | 20 | user_newpassword TEXT, |
21 | 21 | user_newpass_time TIMESTAMPTZ, |
22 | | - user_token CHAR(32), |
| 22 | + user_token TEXT, |
23 | 23 | user_email TEXT, |
24 | | - user_email_token CHAR(32), |
| 24 | + user_email_token TEXT, |
25 | 25 | user_email_token_expires TIMESTAMPTZ, |
26 | 26 | user_email_authenticated TIMESTAMPTZ, |
27 | 27 | user_options TEXT, |
— | — | @@ -127,7 +127,7 @@ |
128 | 128 | CREATE TABLE archive ( |
129 | 129 | ar_namespace SMALLINT NOT NULL, |
130 | 130 | ar_title TEXT NOT NULL, |
131 | | - ar_text TEXT, |
| 131 | + ar_text TEXT, -- technically should be bytea, but not used anymore |
132 | 132 | ar_page_id INTEGER NULL, |
133 | 133 | ar_comment TEXT, |
134 | 134 | ar_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL, |
— | — | @@ -137,7 +137,7 @@ |
138 | 138 | ar_flags TEXT, |
139 | 139 | ar_rev_id INTEGER, |
140 | 140 | ar_text_id INTEGER, |
141 | | - ar_deleted INTEGER NOT NULL DEFAULT 0, |
| 141 | + ar_deleted SMALLINT NOT NULL DEFAULT 0, |
142 | 142 | ar_len INTEGER NULL |
143 | 143 | ); |
144 | 144 | CREATE INDEX archive_name_title_timestamp ON archive (ar_namespace,ar_title,ar_timestamp); |
— | — | @@ -161,7 +161,7 @@ |
162 | 162 | |
163 | 163 | CREATE TABLE templatelinks ( |
164 | 164 | tl_from INTEGER NOT NULL REFERENCES page(page_id) ON DELETE CASCADE, |
165 | | - tl_namespace TEXT NOT NULL, |
| 165 | + tl_namespace SMALLINT NOT NULL, |
166 | 166 | tl_title TEXT NOT NULL |
167 | 167 | ); |
168 | 168 | CREATE UNIQUE INDEX templatelinks_unique ON templatelinks (tl_namespace,tl_title,tl_from); |
— | — | @@ -202,7 +202,7 @@ |
203 | 203 | ss_row_id INTEGER NOT NULL UNIQUE, |
204 | 204 | ss_total_views INTEGER DEFAULT 0, |
205 | 205 | ss_total_edits INTEGER DEFAULT 0, |
206 | | - ss_good_articles INTEGER DEFAULT 0, |
| 206 | + ss_good_articles INTEGER DEFAULT 0, |
207 | 207 | ss_total_pages INTEGER DEFAULT -1, |
208 | 208 | ss_users INTEGER DEFAULT -1, |
209 | 209 | ss_admins INTEGER DEFAULT -1, |
— | — | @@ -229,7 +229,7 @@ |
230 | 230 | ipb_expiry TIMESTAMPTZ NOT NULL, |
231 | 231 | ipb_range_start TEXT, |
232 | 232 | ipb_range_end TEXT, |
233 | | - ipb_deleted INTEGER NOT NULL DEFAULT 0, |
| 233 | + ipb_deleted CHAR NOT NULL DEFAULT '0', |
234 | 234 | ipb_block_email CHAR NOT NULL DEFAULT '0' |
235 | 235 | |
236 | 236 | ); |
— | — | @@ -273,7 +273,7 @@ |
274 | 274 | oi_media_type TEXT NULL, |
275 | 275 | oi_major_mime TEXT NOT NULL DEFAULT 'unknown', |
276 | 276 | oi_minor_mime TEXT NOT NULL DEFAULT 'unknown', |
277 | | - oi_deleted CHAR NOT NULL DEFAULT '0', |
| 277 | + oi_deleted SMALLINT NOT NULL DEFAULT 0, |
278 | 278 | oi_sha1 TEXT NOT NULL DEFAULT '' |
279 | 279 | ); |
280 | 280 | ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascade FOREIGN KEY (oi_name) REFERENCES image(img_name) ON DELETE CASCADE; |
— | — | @@ -286,12 +286,12 @@ |
287 | 287 | fa_id SERIAL NOT NULL PRIMARY KEY, |
288 | 288 | fa_name TEXT NOT NULL, |
289 | 289 | fa_archive_name TEXT, |
290 | | - fa_storage_group VARCHAR(16), |
| 290 | + fa_storage_group TEXT, |
291 | 291 | fa_storage_key TEXT, |
292 | 292 | fa_deleted_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL, |
293 | 293 | fa_deleted_timestamp TIMESTAMPTZ NOT NULL, |
294 | 294 | fa_deleted_reason TEXT, |
295 | | - fa_size SMALLINT NOT NULL, |
| 295 | + fa_size INTEGER NOT NULL, |
296 | 296 | fa_width SMALLINT NOT NULL, |
297 | 297 | fa_height SMALLINT NOT NULL, |
298 | 298 | fa_metadata BYTEA NOT NULL DEFAULT '', |
— | — | @@ -303,7 +303,7 @@ |
304 | 304 | fa_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL, |
305 | 305 | fa_user_text TEXT NOT NULL, |
306 | 306 | fa_timestamp TIMESTAMPTZ, |
307 | | - fa_deleted INTEGER NOT NULL DEFAULT 0 |
| 307 | + fa_deleted SMALLINT NOT NULL DEFAULT 0 |
308 | 308 | ); |
309 | 309 | CREATE INDEX fa_name_time ON filearchive (fa_name, fa_timestamp); |
310 | 310 | CREATE INDEX fa_dupe ON filearchive (fa_storage_group, fa_storage_key); |
— | — | @@ -334,7 +334,7 @@ |
335 | 335 | rc_ip CIDR, |
336 | 336 | rc_old_len INTEGER, |
337 | 337 | rc_new_len INTEGER, |
338 | | - rc_deleted INTEGER NOT NULL DEFAULT 0, |
| 338 | + rc_deleted SMALLINT NOT NULL DEFAULT 0, |
339 | 339 | rc_logid INTEGER NOT NULL DEFAULT 0, |
340 | 340 | rc_log_type TEXT, |
341 | 341 | rc_log_action TEXT, |
— | — | @@ -375,7 +375,7 @@ |
376 | 376 | |
377 | 377 | CREATE TABLE querycache ( |
378 | 378 | qc_type TEXT NOT NULL, |
379 | | - qc_value SMALLINT NOT NULL, |
| 379 | + qc_value INTEGER NOT NULL, |
380 | 380 | qc_namespace SMALLINT NOT NULL, |
381 | 381 | qc_title TEXT NOT NULL |
382 | 382 | ); |
— | — | @@ -388,7 +388,7 @@ |
389 | 389 | |
390 | 390 | CREATE TABLE querycachetwo ( |
391 | 391 | qcc_type TEXT NOT NULL, |
392 | | - qcc_value SMALLINT NOT NULL DEFAULT 0, |
| 392 | + qcc_value INTEGER NOT NULL DEFAULT 0, |
393 | 393 | qcc_namespace INTEGER NOT NULL DEFAULT 0, |
394 | 394 | qcc_title TEXT NOT NULL DEFAULT '', |
395 | 395 | qcc_namespacetwo INTEGER NOT NULL DEFAULT 0, |
— | — | @@ -399,7 +399,7 @@ |
400 | 400 | CREATE INDEX querycachetwo_titletwo ON querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo); |
401 | 401 | |
402 | 402 | CREATE TABLE objectcache ( |
403 | | - keyname CHAR(255) UNIQUE, |
| 403 | + keyname TEXT UNIQUE, |
404 | 404 | value BYTEA NOT NULL DEFAULT '', |
405 | 405 | exptime TIMESTAMPTZ NOT NULL |
406 | 406 | ); |
Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -1351,18 +1351,30 @@ |
1352 | 1352 | |
1353 | 1353 | # table, column, desired type, USING clause if needed |
1354 | 1354 | $typechanges = array( |
| 1355 | + array("archive", "ar_deleted", "smallint", ""), |
| 1356 | + array("filearchive", "fa_deleted", "smallint", ""), |
1355 | 1357 | array("filearchive", "fa_metadata", "bytea", "decode(fa_metadata,'escape')"), |
| 1358 | + array("filearchive", "fa_size", "int4", ""), |
| 1359 | + array("filearchive", "fa_storage_group","text", ""), |
1356 | 1360 | array("filearchive", "fa_storage_key", "text", ""), |
1357 | 1361 | array("image", "img_metadata", "bytea", "decode(img_metadata,'escape')"), |
1358 | 1362 | array("image", "img_size", "int4", ""), |
1359 | 1363 | array("image", "img_width", "int4", ""), |
1360 | 1364 | array("image", "img_height", "int4", ""), |
1361 | 1365 | array("ipblocks", "ipb_address", "text", "ipb_address::text"), |
| 1366 | + array("ipblocks", "ipb_deleted", "char", ""), |
1362 | 1367 | array("math", "math_inputhash", "bytea", "decode(math_inputhash,'escape')"), |
1363 | 1368 | array("math", "math_outputhash", "bytea", "decode(math_outputhash,'escape')"), |
| 1369 | + array("mwuser", "user_token", "text", ""), |
| 1370 | + array("mwuser", "user_email_token","text", ""), |
| 1371 | + array("objectcache", "keyname", "text", ""), |
| 1372 | + array("oldimage", "oi_height", "int4", ""), |
1364 | 1373 | array("oldimage", "oi_size", "int4", ""), |
1365 | 1374 | array("oldimage", "oi_width", "int4", ""), |
1366 | | - array("oldimage", "oi_height", "int4", ""), |
| 1375 | + array("querycache", "qc_value", "int4", ""), |
| 1376 | + array("querycachetwo","qcc_value", "int4", ""), |
| 1377 | + array("recentchanges","rc_deleted", "smallint", ""), |
| 1378 | + array("templatelinks","tl_namespace", "smallint", "tl_namespace::smallint"), |
1367 | 1379 | array("user_newtalk", "user_ip", "text", "host(user_ip)"), |
1368 | 1380 | ); |
1369 | 1381 | |
— | — | @@ -1443,6 +1455,13 @@ |
1444 | 1456 | } |
1445 | 1457 | } |
1446 | 1458 | |
| 1459 | + if ($wgDatabase->fieldInfo('oldimage','oi_deleted') !== 'smallint') { |
| 1460 | + echo "... change oldimage.oi_deleted to smallint"; |
| 1461 | + $wgDatabase->query("ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT"); |
| 1462 | + $wgDatabase->query("ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)"); |
| 1463 | + $wgDatabase->query("ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0"); |
| 1464 | + } |
| 1465 | + |
1447 | 1466 | foreach ($newindexes as $ni) { |
1448 | 1467 | if (pg_index_exists($ni[0], $ni[1])) { |
1449 | 1468 | echo "... index $ni[1] on $ni[0] already exists\n"; |