Index: trunk/phase3/maintenance/postgres/tables.sql |
— | — | @@ -82,9 +82,9 @@ |
83 | 83 | CREATE TRIGGER page_deleted AFTER DELETE ON page |
84 | 84 | FOR EACH ROW EXECUTE PROCEDURE page_deleted(); |
85 | 85 | |
86 | | -CREATE SEQUENCE rev_rev_id_val; |
| 86 | +CREATE SEQUENCE revision_rev_id_seq; |
87 | 87 | CREATE TABLE revision ( |
88 | | - rev_id INTEGER NOT NULL UNIQUE DEFAULT nextval('rev_rev_id_val'), |
| 88 | + rev_id INTEGER NOT NULL UNIQUE DEFAULT nextval('revision_rev_id_seq'), |
89 | 89 | rev_page INTEGER NULL REFERENCES page (page_id) ON DELETE CASCADE, |
90 | 90 | rev_text_id INTEGER NULL, -- FK |
91 | 91 | rev_comment TEXT, |
— | — | @@ -103,17 +103,17 @@ |
104 | 104 | CREATE INDEX rev_user_text_idx ON revision (rev_user_text); |
105 | 105 | |
106 | 106 | |
107 | | -CREATE SEQUENCE text_old_id_val; |
| 107 | +CREATE SEQUENCE text_old_id_seq; |
108 | 108 | CREATE TABLE pagecontent ( -- replaces reserved word 'text' |
109 | | - old_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('text_old_id_val'), |
| 109 | + old_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('text_old_id_seq'), |
110 | 110 | old_text TEXT, |
111 | 111 | old_flags TEXT |
112 | 112 | ); |
113 | 113 | |
114 | 114 | |
115 | | -CREATE SEQUENCE pr_id_val; |
| 115 | +CREATE SEQUENCE page_restrictions_pr_id_seq; |
116 | 116 | CREATE TABLE page_restrictions ( |
117 | | - pr_id INTEGER NOT NULL UNIQUE DEFAULT nextval('pr_id_val'), |
| 117 | + pr_id INTEGER NOT NULL UNIQUE DEFAULT nextval('page_restrictions_pr_id_seq'), |
118 | 118 | pr_page INTEGER NULL REFERENCES page (page_id) ON DELETE CASCADE, |
119 | 119 | pr_type TEXT NOT NULL, |
120 | 120 | pr_level TEXT NOT NULL, |
— | — | @@ -233,9 +233,9 @@ |
234 | 234 | ); |
235 | 235 | |
236 | 236 | |
237 | | -CREATE SEQUENCE ipblocks_ipb_id_val; |
| 237 | +CREATE SEQUENCE ipblocks_ipb_id_seq; |
238 | 238 | CREATE TABLE ipblocks ( |
239 | | - ipb_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('ipblocks_ipb_id_val'), |
| 239 | + ipb_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('ipblocks_ipb_id_seq'), |
240 | 240 | ipb_address TEXT NULL, |
241 | 241 | ipb_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL, |
242 | 242 | ipb_by INTEGER NOT NULL REFERENCES mwuser(user_id) ON DELETE CASCADE, |
— | — | @@ -333,9 +333,9 @@ |
334 | 334 | CREATE INDEX fa_nouser ON filearchive (fa_deleted_user); |
335 | 335 | |
336 | 336 | |
337 | | -CREATE SEQUENCE rc_rc_id_seq; |
| 337 | +CREATE SEQUENCE recentchanges_rc_id_seq; |
338 | 338 | CREATE TABLE recentchanges ( |
339 | | - rc_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('rc_rc_id_seq'), |
| 339 | + rc_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('recentchanges_rc_id_seq'), |
340 | 340 | rc_timestamp TIMESTAMPTZ NOT NULL, |
341 | 341 | rc_cur_time TIMESTAMPTZ NOT NULL, |
342 | 342 | rc_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL, |
— | — | @@ -435,9 +435,9 @@ |
436 | 436 | ); |
437 | 437 | |
438 | 438 | |
439 | | -CREATE SEQUENCE log_log_id_seq; |
| 439 | +CREATE SEQUENCE logging_log_id_seq; |
440 | 440 | CREATE TABLE logging ( |
441 | | - log_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('log_log_id_seq'), |
| 441 | + log_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('logging_log_id_seq'), |
442 | 442 | log_type TEXT NOT NULL, |
443 | 443 | log_action TEXT NOT NULL, |
444 | 444 | log_timestamp TIMESTAMPTZ NOT NULL, |
— | — | @@ -563,9 +563,9 @@ |
564 | 564 | ); |
565 | 565 | |
566 | 566 | |
567 | | -CREATE SEQUENCE category_id_seq; |
| 567 | +CREATE SEQUENCE category_cat_id_seq; |
568 | 568 | CREATE TABLE category ( |
569 | | - cat_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('category_id_seq'), |
| 569 | + cat_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('category_cat_id_seq'), |
570 | 570 | cat_title TEXT NOT NULL, |
571 | 571 | cat_pages INTEGER NOT NULL DEFAULT 0, |
572 | 572 | cat_subcats INTEGER NOT NULL DEFAULT 0, |
Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -1402,6 +1402,15 @@ |
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | function |
| 1406 | +pg_sequence_exists($seq) |
| 1407 | +{ |
| 1408 | +global $wgDatabase, $wgDBmwschema; |
| 1409 | + $exists = $wgDatabase->selectField("pg_class","relname", |
| 1410 | + array( "relname" => $seq ) ); |
| 1411 | + return $exists === $seq; |
| 1412 | +} |
| 1413 | + |
| 1414 | +function |
1406 | 1415 | pg_fkey_deltype($fkey) |
1407 | 1416 | { |
1408 | 1417 | global $wgDatabase, $wgDBmwschema; |
— | — | @@ -1504,8 +1513,8 @@ |
1505 | 1514 | } |
1506 | 1515 | |
1507 | 1516 | $newsequences = array( |
1508 | | - "log_log_id_seq", |
1509 | | - "pr_id_val", |
| 1517 | + "logging_log_id_seq", |
| 1518 | + "page_restrictions_pr_id_seq", |
1510 | 1519 | ); |
1511 | 1520 | |
1512 | 1521 | $newtables = array( |
— | — | @@ -1830,6 +1839,14 @@ |
1831 | 1840 | $wgDatabase->sourceFile(archive('patch-revision_rev_user_fkey.sql')); |
1832 | 1841 | } |
1833 | 1842 | |
| 1843 | + #Update sequence names |
| 1844 | + if (pg_sequence_exists('page_restrictions_pr_id_seq')) { |
| 1845 | + wfOut( "... sequences already updated\n" ); |
| 1846 | + } else { |
| 1847 | + wfOut( "Updating sequence names\n" ); |
| 1848 | + $wgDatabase->sourceFile(archive('patch-update_sequences.sql')); |
| 1849 | + } |
| 1850 | + |
1834 | 1851 | # Fix ipb_address index |
1835 | 1852 | if (pg_index_exists('ipblocks', 'ipb_address' )) { |
1836 | 1853 | wfOut( "Removing deprecated index 'ipb_address'...\n" ); |