Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -1332,7 +1332,7 @@ |
1333 | 1333 | array("page_restrictions", "patch-page_restrictions.sql"), |
1334 | 1334 | array("profiling", "patch-profiling.sql"), |
1335 | 1335 | array("mediawiki_version", "patch-mediawiki_version.sql"), |
1336 | | - array("archive2", "patch-archive2.sql") |
| 1336 | + // array("archive2", "patch-archive2.sql") |
1337 | 1337 | ); |
1338 | 1338 | |
1339 | 1339 | $newsequences = array( |
— | — | @@ -1344,7 +1344,8 @@ |
1345 | 1345 | ); |
1346 | 1346 | |
1347 | 1347 | $newrules = array( |
1348 | | - array("archive", "archive_delete", "patch-archive_delete.sql") |
| 1348 | + //array("archive", "archive_delete", |
| 1349 | + //"patch-archive_delete.sql") |
1349 | 1350 | ); |
1350 | 1351 | |
1351 | 1352 | foreach ($newsequences as $ns) { |
— | — | @@ -1449,18 +1450,26 @@ |
1450 | 1451 | dbsource(archive('patch-revision_rev_user_fkey.sql')); |
1451 | 1452 | } |
1452 | 1453 | |
1453 | | - $ai_def = pg_rule_def("archive", "archive_insert"); |
1454 | | - if (strstr($ai_def, "to_date") !== false) { |
1455 | | - echo "... fix archive_insert rule\n"; |
1456 | | - dbsource(archive('patch-archive_insert.sql')); |
| 1454 | + if (pg_table_exists("archive2")) { |
| 1455 | + echo "... convert archive2 back to normal archive table\n"; |
| 1456 | + if (pg_rule_exists("archive", "archive_insert")) { |
| 1457 | + echo "... drop rule archive_insert\n"; |
| 1458 | + $wgDatabase->query("DROP RULE archive_insert ON archive"); |
| 1459 | + } |
| 1460 | + if (pg_rule_exists("archive", "archive_delete")) { |
| 1461 | + echo "... drop rule archive_delete\n"; |
| 1462 | + $wgDatabase->query("DROP RULE archive_delete ON archive"); |
| 1463 | + } |
| 1464 | + |
| 1465 | + dbsource(archive("patch-remove-archive2.sql")); |
1457 | 1466 | } else |
1458 | | - echo "... already have correct archive_insert rule\n"; |
| 1467 | + echo "... obsolete archive2 not present\n"; |
1459 | 1468 | |
1460 | | - if (!pg_column_exists("archive2", "ar_deleted")) { |
1461 | | - echo "... add archive2.ar_deleted and recreate archive view\n"; |
1462 | | - dbsource(archive("patch-archive2-ar_deleted.sql")); |
| 1469 | + if (!pg_column_exists("archive", "ar_deleted")) { |
| 1470 | + echo "... add archive.ar_deleted\n"; |
| 1471 | + dbsource(archive("patch-archive-ar_deleted.sql")); |
1463 | 1472 | } else |
1464 | | - echo "... already have archive2.ar_deleted\n"; |
| 1473 | + echo "... archive.ar_deleted already exists\n"; |
1465 | 1474 | |
1466 | 1475 | return; |
1467 | 1476 | } |
Index: trunk/phase3/maintenance/postgres/archives/patch-archive2-ar_deleted.sql |
— | — | @@ -1,17 +0,0 @@ |
2 | | -ALTER TABLE archive2 ADD ar_deleted INTEGER NOT NULL DEFAULT '0'; |
3 | | -DROP VIEW archive; |
4 | | - |
5 | | -CREATE VIEW archive AS |
6 | | -SELECT |
7 | | - ar_namespace, ar_title, ar_text, ar_comment, ar_user, ar_user_text, |
8 | | - ar_minor_edit, ar_flags, ar_rev_id, ar_text_id, ar_deleted, |
9 | | - TO_CHAR(ar_timestamp, 'YYYYMMDDHH24MISS') AS ar_timestamp |
10 | | -FROM archive2; |
11 | | - |
12 | | -CREATE RULE archive_insert AS ON INSERT TO archive |
13 | | -DO INSTEAD INSERT INTO archive2 VALUES ( |
14 | | - NEW.ar_namespace, NEW.ar_title, NEW.ar_text, NEW.ar_comment, NEW.ar_user, NEW.ar_user_text, |
15 | | - TO_TIMESTAMP(NEW.ar_timestamp, 'YYYYMMDDHH24MISS'), |
16 | | - NEW.ar_minor_edit, NEW.ar_flags, NEW.ar_rev_id, NEW.ar_text_id, |
17 | | - COALESCE(NEW.ar_deleted, 0) -- ar_deleted is not always specified |
18 | | -); |
Index: trunk/phase3/maintenance/postgres/archives/patch-remove-archive2.sql |
— | — | @@ -0,0 +1,2 @@ |
| 2 | +DROP VIEW archive; |
| 3 | +ALTER TABLE archive2 RENAME TO archive; |
Index: trunk/phase3/maintenance/postgres/archives/patch-archive-ar_deleted.sql |
— | — | @@ -0,0 +1 @@ |
| 2 | +ALTER TABLE archive ADD ar_deleted INTEGER NOT NULL DEFAULT '0'; |
Index: trunk/phase3/maintenance/postgres/tables.sql |
— | — | @@ -123,8 +123,7 @@ |
124 | 124 | ); |
125 | 125 | ALTER TABLE page_restrictions ADD CONSTRAINT page_restrictions_pk PRIMARY KEY (pr_page,pr_type); |
126 | 126 | |
127 | | - |
128 | | -CREATE TABLE archive2 ( |
| 127 | +CREATE TABLE archive ( |
129 | 128 | ar_namespace SMALLINT NOT NULL, |
130 | 129 | ar_title TEXT NOT NULL, |
131 | 130 | ar_text TEXT, |
— | — | @@ -140,29 +139,6 @@ |
141 | 140 | ); |
142 | 141 | CREATE INDEX archive_name_title_timestamp ON archive2 (ar_namespace,ar_title,ar_timestamp); |
143 | 142 | |
144 | | -CREATE VIEW archive AS |
145 | | -SELECT |
146 | | - ar_namespace, ar_title, ar_text, ar_comment, ar_user, ar_user_text, |
147 | | - ar_minor_edit, ar_flags, ar_rev_id, ar_text_id, ar_deleted, |
148 | | - TO_CHAR(ar_timestamp, 'YYYYMMDDHH24MISS') AS ar_timestamp |
149 | | -FROM archive2; |
150 | | - |
151 | | -CREATE RULE archive_insert AS ON INSERT TO archive |
152 | | -DO INSTEAD INSERT INTO archive2 VALUES ( |
153 | | - NEW.ar_namespace, NEW.ar_title, NEW.ar_text, NEW.ar_comment, NEW.ar_user, NEW.ar_user_text, |
154 | | - TO_TIMESTAMP(NEW.ar_timestamp, 'YYYYMMDDHH24MISS'), |
155 | | - NEW.ar_minor_edit, NEW.ar_flags, NEW.ar_rev_id, NEW.ar_text_id, |
156 | | - COALESCE(NEW.ar_deleted, 0) -- NEW.ar_deleted might be unspecified (NULL) |
157 | | -); |
158 | | - |
159 | | -CREATE RULE archive_delete AS ON DELETE TO archive |
160 | | -DO INSTEAD DELETE FROM archive2 WHERE |
161 | | - archive2.ar_title = OLD.ar_title AND |
162 | | - archive2.ar_namespace = OLD.ar_namespace AND |
163 | | - archive2.ar_rev_id = OLD.ar_rev_id; |
164 | | - |
165 | | - |
166 | 143 | CREATE TABLE redirect ( |
167 | 144 | rd_from INTEGER NOT NULL REFERENCES page(page_id) ON DELETE CASCADE, |
168 | 145 | rd_namespace SMALLINT NOT NULL, |