r26086 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26085‎ | r26086 | r26087 >
Date:20:10, 24 September 2007
Author:greg
Status:old
Tags:
Comment:
Major cleanup of schema, based on new compare_schemas.pl functionality.
Modified paths:
  • /trunk/phase3/maintenance/postgres/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/postgres/tables.sql
@@ -18,9 +18,9 @@
1919 user_password TEXT,
2020 user_newpassword TEXT,
2121 user_newpass_time TIMESTAMPTZ,
22 - user_token CHAR(32),
 22+ user_token TEXT,
2323 user_email TEXT,
24 - user_email_token CHAR(32),
 24+ user_email_token TEXT,
2525 user_email_token_expires TIMESTAMPTZ,
2626 user_email_authenticated TIMESTAMPTZ,
2727 user_options TEXT,
@@ -127,7 +127,7 @@
128128 CREATE TABLE archive (
129129 ar_namespace SMALLINT NOT NULL,
130130 ar_title TEXT NOT NULL,
131 - ar_text TEXT,
 131+ ar_text TEXT, -- technically should be bytea, but not used anymore
132132 ar_page_id INTEGER NULL,
133133 ar_comment TEXT,
134134 ar_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL,
@@ -137,7 +137,7 @@
138138 ar_flags TEXT,
139139 ar_rev_id INTEGER,
140140 ar_text_id INTEGER,
141 - ar_deleted INTEGER NOT NULL DEFAULT 0,
 141+ ar_deleted SMALLINT NOT NULL DEFAULT 0,
142142 ar_len INTEGER NULL
143143 );
144144 CREATE INDEX archive_name_title_timestamp ON archive (ar_namespace,ar_title,ar_timestamp);
@@ -161,7 +161,7 @@
162162
163163 CREATE TABLE templatelinks (
164164 tl_from INTEGER NOT NULL REFERENCES page(page_id) ON DELETE CASCADE,
165 - tl_namespace TEXT NOT NULL,
 165+ tl_namespace SMALLINT NOT NULL,
166166 tl_title TEXT NOT NULL
167167 );
168168 CREATE UNIQUE INDEX templatelinks_unique ON templatelinks (tl_namespace,tl_title,tl_from);
@@ -202,7 +202,7 @@
203203 ss_row_id INTEGER NOT NULL UNIQUE,
204204 ss_total_views INTEGER DEFAULT 0,
205205 ss_total_edits INTEGER DEFAULT 0,
206 - ss_good_articles INTEGER DEFAULT 0,
 206+ ss_good_articles INTEGER DEFAULT 0,
207207 ss_total_pages INTEGER DEFAULT -1,
208208 ss_users INTEGER DEFAULT -1,
209209 ss_admins INTEGER DEFAULT -1,
@@ -229,7 +229,7 @@
230230 ipb_expiry TIMESTAMPTZ NOT NULL,
231231 ipb_range_start TEXT,
232232 ipb_range_end TEXT,
233 - ipb_deleted INTEGER NOT NULL DEFAULT 0,
 233+ ipb_deleted CHAR NOT NULL DEFAULT '0',
234234 ipb_block_email CHAR NOT NULL DEFAULT '0'
235235
236236 );
@@ -273,7 +273,7 @@
274274 oi_media_type TEXT NULL,
275275 oi_major_mime TEXT NOT NULL DEFAULT 'unknown',
276276 oi_minor_mime TEXT NOT NULL DEFAULT 'unknown',
277 - oi_deleted CHAR NOT NULL DEFAULT '0',
 277+ oi_deleted SMALLINT NOT NULL DEFAULT 0,
278278 oi_sha1 TEXT NOT NULL DEFAULT ''
279279 );
280280 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 @@
287287 fa_id SERIAL NOT NULL PRIMARY KEY,
288288 fa_name TEXT NOT NULL,
289289 fa_archive_name TEXT,
290 - fa_storage_group VARCHAR(16),
 290+ fa_storage_group TEXT,
291291 fa_storage_key TEXT,
292292 fa_deleted_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL,
293293 fa_deleted_timestamp TIMESTAMPTZ NOT NULL,
294294 fa_deleted_reason TEXT,
295 - fa_size SMALLINT NOT NULL,
 295+ fa_size INTEGER NOT NULL,
296296 fa_width SMALLINT NOT NULL,
297297 fa_height SMALLINT NOT NULL,
298298 fa_metadata BYTEA NOT NULL DEFAULT '',
@@ -303,7 +303,7 @@
304304 fa_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL,
305305 fa_user_text TEXT NOT NULL,
306306 fa_timestamp TIMESTAMPTZ,
307 - fa_deleted INTEGER NOT NULL DEFAULT 0
 307+ fa_deleted SMALLINT NOT NULL DEFAULT 0
308308 );
309309 CREATE INDEX fa_name_time ON filearchive (fa_name, fa_timestamp);
310310 CREATE INDEX fa_dupe ON filearchive (fa_storage_group, fa_storage_key);
@@ -334,7 +334,7 @@
335335 rc_ip CIDR,
336336 rc_old_len INTEGER,
337337 rc_new_len INTEGER,
338 - rc_deleted INTEGER NOT NULL DEFAULT 0,
 338+ rc_deleted SMALLINT NOT NULL DEFAULT 0,
339339 rc_logid INTEGER NOT NULL DEFAULT 0,
340340 rc_log_type TEXT,
341341 rc_log_action TEXT,
@@ -375,7 +375,7 @@
376376
377377 CREATE TABLE querycache (
378378 qc_type TEXT NOT NULL,
379 - qc_value SMALLINT NOT NULL,
 379+ qc_value INTEGER NOT NULL,
380380 qc_namespace SMALLINT NOT NULL,
381381 qc_title TEXT NOT NULL
382382 );
@@ -388,7 +388,7 @@
389389
390390 CREATE TABLE querycachetwo (
391391 qcc_type TEXT NOT NULL,
392 - qcc_value SMALLINT NOT NULL DEFAULT 0,
 392+ qcc_value INTEGER NOT NULL DEFAULT 0,
393393 qcc_namespace INTEGER NOT NULL DEFAULT 0,
394394 qcc_title TEXT NOT NULL DEFAULT '',
395395 qcc_namespacetwo INTEGER NOT NULL DEFAULT 0,
@@ -399,7 +399,7 @@
400400 CREATE INDEX querycachetwo_titletwo ON querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
401401
402402 CREATE TABLE objectcache (
403 - keyname CHAR(255) UNIQUE,
 403+ keyname TEXT UNIQUE,
404404 value BYTEA NOT NULL DEFAULT '',
405405 exptime TIMESTAMPTZ NOT NULL
406406 );
Index: trunk/phase3/maintenance/updaters.inc
@@ -1351,18 +1351,30 @@
13521352
13531353 # table, column, desired type, USING clause if needed
13541354 $typechanges = array(
 1355+ array("archive", "ar_deleted", "smallint", ""),
 1356+ array("filearchive", "fa_deleted", "smallint", ""),
13551357 array("filearchive", "fa_metadata", "bytea", "decode(fa_metadata,'escape')"),
 1358+ array("filearchive", "fa_size", "int4", ""),
 1359+ array("filearchive", "fa_storage_group","text", ""),
13561360 array("filearchive", "fa_storage_key", "text", ""),
13571361 array("image", "img_metadata", "bytea", "decode(img_metadata,'escape')"),
13581362 array("image", "img_size", "int4", ""),
13591363 array("image", "img_width", "int4", ""),
13601364 array("image", "img_height", "int4", ""),
13611365 array("ipblocks", "ipb_address", "text", "ipb_address::text"),
 1366+ array("ipblocks", "ipb_deleted", "char", ""),
13621367 array("math", "math_inputhash", "bytea", "decode(math_inputhash,'escape')"),
13631368 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", ""),
13641373 array("oldimage", "oi_size", "int4", ""),
13651374 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"),
13671379 array("user_newtalk", "user_ip", "text", "host(user_ip)"),
13681380 );
13691381
@@ -1443,6 +1455,13 @@
14441456 }
14451457 }
14461458
 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+
14471466 foreach ($newindexes as $ni) {
14481467 if (pg_index_exists($ni[0], $ni[1])) {
14491468 echo "... index $ni[1] on $ni[0] already exists\n";

Follow-up revisions

RevisionCommit summaryAuthorDate
r26135Merged revisions 26012-26133 via svnmerge from...david21:15, 25 September 2007

Status & tagging log