MediaWiki  master
PostgresUpdater.php
Go to the documentation of this file.
1 <?php
25 
33 
37  protected $db;
38 
44  protected function getCoreUpdateList() {
45  return [
46  # rename tables 1.7.3
47  # r15791 Change reserved word table names "user" and "text"
48  [ 'renameTable', 'user', 'mwuser' ],
49  [ 'renameTable', 'text', 'pagecontent' ],
50  [ 'renameIndex', 'mwuser', 'user_pkey', 'mwuser_pkey' ],
51  [ 'renameIndex', 'mwuser', 'user_user_name_key', 'mwuser_user_name_key' ],
52  [ 'renameIndex', 'pagecontent', 'text_pkey', 'pagecontent_pkey' ],
53 
54  # renamed sequences
55  [ 'renameSequence', 'ipblocks_ipb_id_val', 'ipblocks_ipb_id_seq' ],
56  [ 'renameSequence', 'rev_rev_id_val', 'revision_rev_id_seq' ],
57  [ 'renameSequence', 'text_old_id_val', 'text_old_id_seq' ],
58  [ 'renameSequence', 'rc_rc_id_seq', 'recentchanges_rc_id_seq' ],
59  [ 'renameSequence', 'log_log_id_seq', 'logging_log_id_seq' ],
60  [ 'renameSequence', 'pr_id_val', 'page_restrictions_pr_id_seq' ],
61  [ 'renameSequence', 'us_id_seq', 'uploadstash_us_id_seq' ],
62 
63  # since r58263
64  [ 'renameSequence', 'category_id_seq', 'category_cat_id_seq' ],
65 
66  # new sequences if not renamed above
67  [ 'addSequence', 'logging', false, 'logging_log_id_seq' ],
68  [ 'addSequence', 'page_restrictions', false, 'page_restrictions_pr_id_seq' ],
69  [ 'addSequence', 'filearchive', 'fa_id', 'filearchive_fa_id_seq' ],
70  [ 'addSequence', 'archive', false, 'archive_ar_id_seq' ],
71  [ 'addSequence', 'externallinks', false, 'externallinks_el_id_seq' ],
72  [ 'addSequence', 'watchlist', false, 'watchlist_wl_id_seq' ],
73  [ 'addSequence', 'change_tag', false, 'change_tag_ct_id_seq' ],
74 
75  # new tables
76  [ 'addTable', 'category', 'patch-category.sql' ],
77  [ 'addTable', 'page', 'patch-page.sql' ],
78  [ 'addTable', 'querycachetwo', 'patch-querycachetwo.sql' ],
79  [ 'addTable', 'page_props', 'patch-page_props.sql' ],
80  [ 'addTable', 'page_restrictions', 'patch-page_restrictions.sql' ],
81  [ 'addTable', 'protected_titles', 'patch-protected_titles.sql' ],
82  [ 'addTable', 'redirect', 'patch-redirect.sql' ],
83  [ 'addTable', 'updatelog', 'patch-updatelog.sql' ],
84  [ 'addTable', 'change_tag', 'patch-change_tag.sql' ],
85  [ 'addTable', 'user_properties', 'patch-user_properties.sql' ],
86  [ 'addTable', 'log_search', 'patch-log_search.sql' ],
87  [ 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ],
88  [ 'addTable', 'iwlinks', 'patch-iwlinks.sql' ],
89  [ 'addTable', 'module_deps', 'patch-module_deps.sql' ],
90  [ 'addTable', 'uploadstash', 'patch-uploadstash.sql' ],
91  [ 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ],
92  [ 'addTable', 'sites', 'patch-sites.sql' ],
93  [ 'addTable', 'bot_passwords', 'patch-bot_passwords.sql' ],
94 
95  # Needed before new field
96  [ 'convertArchive2' ],
97 
98  # new fields
99  [ 'addPgField', 'updatelog', 'ul_value', 'TEXT' ],
100  [ 'addPgField', 'archive', 'ar_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
101  [ 'addPgField', 'archive', 'ar_len', 'INTEGER' ],
102  [ 'addPgField', 'archive', 'ar_page_id', 'INTEGER' ],
103  [ 'addPgField', 'archive', 'ar_parent_id', 'INTEGER' ],
104  [ 'addPgField', 'archive', 'ar_content_model', 'TEXT' ],
105  [ 'addPgField', 'archive', 'ar_content_format', 'TEXT' ],
106  [ 'addPgField', 'categorylinks', 'cl_sortkey_prefix', "TEXT NOT NULL DEFAULT ''" ],
107  [ 'addPgField', 'categorylinks', 'cl_collation', "TEXT NOT NULL DEFAULT 0" ],
108  [ 'addPgField', 'categorylinks', 'cl_type', "TEXT NOT NULL DEFAULT 'page'" ],
109  [ 'addPgField', 'image', 'img_sha1', "TEXT NOT NULL DEFAULT ''" ],
110  [ 'addPgField', 'ipblocks', 'ipb_allow_usertalk', 'SMALLINT NOT NULL DEFAULT 0' ],
111  [ 'addPgField', 'ipblocks', 'ipb_anon_only', 'SMALLINT NOT NULL DEFAULT 0' ],
112  [ 'ifNoActorTable', 'addPgField', 'ipblocks', 'ipb_by_text', "TEXT NOT NULL DEFAULT ''" ],
113  [ 'addPgField', 'ipblocks', 'ipb_block_email', 'SMALLINT NOT NULL DEFAULT 0' ],
114  [ 'addPgField', 'ipblocks', 'ipb_create_account', 'SMALLINT NOT NULL DEFAULT 1' ],
115  [ 'addPgField', 'ipblocks', 'ipb_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
116  [ 'addPgField', 'ipblocks', 'ipb_enable_autoblock', 'SMALLINT NOT NULL DEFAULT 1' ],
117  [ 'addPgField', 'ipblocks', 'ipb_parent_block_id',
118  'INTEGER DEFAULT NULL REFERENCES ipblocks(ipb_id) ' .
119  'ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED' ],
120  [ 'addPgField', 'filearchive', 'fa_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
121  [ 'addPgField', 'filearchive', 'fa_sha1', "TEXT NOT NULL DEFAULT ''" ],
122  [ 'addPgField', 'logging', 'log_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
123  [ 'addPgField', 'logging', 'log_id',
124  "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('logging_log_id_seq')" ],
125  [ 'addPgField', 'logging', 'log_params', 'TEXT' ],
126  [ 'addPgField', 'mwuser', 'user_editcount', 'INTEGER' ],
127  [ 'addPgField', 'mwuser', 'user_newpass_time', 'TIMESTAMPTZ' ],
128  [ 'addPgField', 'oldimage', 'oi_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
129  [ 'addPgField', 'oldimage', 'oi_major_mime', "TEXT NOT NULL DEFAULT 'unknown'" ],
130  [ 'addPgField', 'oldimage', 'oi_media_type', 'TEXT' ],
131  [ 'addPgField', 'oldimage', 'oi_metadata', "BYTEA NOT NULL DEFAULT ''" ],
132  [ 'addPgField', 'oldimage', 'oi_minor_mime', "TEXT NOT NULL DEFAULT 'unknown'" ],
133  [ 'addPgField', 'oldimage', 'oi_sha1', "TEXT NOT NULL DEFAULT ''" ],
134  [ 'addPgField', 'page', 'page_content_model', 'TEXT' ],
135  [ 'addPgField', 'page_restrictions', 'pr_id',
136  "INTEGER NOT NULL UNIQUE DEFAULT nextval('page_restrictions_pr_id_seq')" ],
137  [ 'addPgField', 'recentchanges', 'rc_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
138  [ 'addPgField', 'recentchanges', 'rc_log_action', 'TEXT' ],
139  [ 'addPgField', 'recentchanges', 'rc_log_type', 'TEXT' ],
140  [ 'addPgField', 'recentchanges', 'rc_logid', 'INTEGER NOT NULL DEFAULT 0' ],
141  [ 'addPgField', 'recentchanges', 'rc_new_len', 'INTEGER' ],
142  [ 'addPgField', 'recentchanges', 'rc_old_len', 'INTEGER' ],
143  [ 'addPgField', 'recentchanges', 'rc_params', 'TEXT' ],
144  [ 'addPgField', 'redirect', 'rd_interwiki', 'TEXT NULL' ],
145  [ 'addPgField', 'redirect', 'rd_fragment', 'TEXT NULL' ],
146  [ 'addPgField', 'revision', 'rev_deleted', 'SMALLINT NOT NULL DEFAULT 0' ],
147  [ 'addPgField', 'revision', 'rev_len', 'INTEGER' ],
148  [ 'addPgField', 'revision', 'rev_parent_id', 'INTEGER DEFAULT NULL' ],
149  [ 'addPgField', 'revision', 'rev_content_model', 'TEXT' ],
150  [ 'addPgField', 'revision', 'rev_content_format', 'TEXT' ],
151  [ 'addPgField', 'site_stats', 'ss_active_users', "INTEGER DEFAULT '-1'" ],
152  [ 'addPgField', 'user_newtalk', 'user_last_timestamp', 'TIMESTAMPTZ' ],
153  [ 'ifNoActorTable', 'addPgField', 'logging', 'log_user_text', "TEXT NOT NULL DEFAULT ''" ],
154  [ 'addPgField', 'logging', 'log_page', 'INTEGER' ],
155  [ 'addPgField', 'interwiki', 'iw_api', "TEXT NOT NULL DEFAULT ''" ],
156  [ 'addPgField', 'interwiki', 'iw_wikiid', "TEXT NOT NULL DEFAULT ''" ],
157  [ 'addPgField', 'revision', 'rev_sha1', "TEXT NOT NULL DEFAULT ''" ],
158  [ 'addPgField', 'archive', 'ar_sha1', "TEXT NOT NULL DEFAULT ''" ],
159  [ 'addPgField', 'uploadstash', 'us_chunk_inx', "INTEGER NULL" ],
160  [ 'addPgField', 'job', 'job_timestamp', "TIMESTAMPTZ" ],
161  [ 'addPgField', 'job', 'job_random', "INTEGER NOT NULL DEFAULT 0" ],
162  [ 'addPgField', 'job', 'job_attempts', "INTEGER NOT NULL DEFAULT 0" ],
163  [ 'addPgField', 'job', 'job_token', "TEXT NOT NULL DEFAULT ''" ],
164  [ 'addPgField', 'job', 'job_token_timestamp', "TIMESTAMPTZ" ],
165  [ 'addPgField', 'job', 'job_sha1', "TEXT NOT NULL DEFAULT ''" ],
166  [ 'addPgField', 'archive', 'ar_id',
167  "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('archive_ar_id_seq')" ],
168  [ 'addPgField', 'externallinks', 'el_id',
169  "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('externallinks_el_id_seq')" ],
170  [ 'addPgField', 'uploadstash', 'us_props', "BYTEA" ],
171 
172  # type changes
173  [ 'changeField', 'archive', 'ar_deleted', 'smallint', '' ],
174  [ 'changeField', 'archive', 'ar_minor_edit', 'smallint',
175  'ar_minor_edit::smallint DEFAULT 0' ],
176  [ 'changeField', 'filearchive', 'fa_deleted', 'smallint', '' ],
177  [ 'changeField', 'filearchive', 'fa_height', 'integer', '' ],
178  [ 'changeField', 'filearchive', 'fa_metadata', 'bytea', "decode(fa_metadata,'escape')" ],
179  [ 'changeField', 'filearchive', 'fa_size', 'integer', '' ],
180  [ 'changeField', 'filearchive', 'fa_width', 'integer', '' ],
181  [ 'changeField', 'filearchive', 'fa_storage_group', 'text', '' ],
182  [ 'changeField', 'filearchive', 'fa_storage_key', 'text', '' ],
183  [ 'changeField', 'image', 'img_metadata', 'bytea', "decode(img_metadata,'escape')" ],
184  [ 'changeField', 'image', 'img_size', 'integer', '' ],
185  [ 'changeField', 'image', 'img_width', 'integer', '' ],
186  [ 'changeField', 'image', 'img_height', 'integer', '' ],
187  [ 'changeField', 'interwiki', 'iw_local', 'smallint', 'iw_local::smallint' ],
188  [ 'changeField', 'interwiki', 'iw_trans', 'smallint', 'iw_trans::smallint DEFAULT 0' ],
189  [ 'changeField', 'ipblocks', 'ipb_auto', 'smallint', 'ipb_auto::smallint DEFAULT 0' ],
190  [ 'changeField', 'ipblocks', 'ipb_anon_only', 'smallint',
191  "CASE WHEN ipb_anon_only=' ' THEN 0 ELSE ipb_anon_only::smallint END DEFAULT 0" ],
192  [ 'changeField', 'ipblocks', 'ipb_create_account', 'smallint',
193  "CASE WHEN ipb_create_account=' ' THEN 0 ELSE ipb_create_account::smallint END DEFAULT 1" ],
194  [ 'changeField', 'ipblocks', 'ipb_enable_autoblock', 'smallint',
195  "CASE WHEN ipb_enable_autoblock=' ' THEN 0 ELSE ipb_enable_autoblock::smallint END DEFAULT 1" ],
196  [ 'changeField', 'ipblocks', 'ipb_block_email', 'smallint',
197  "CASE WHEN ipb_block_email=' ' THEN 0 ELSE ipb_block_email::smallint END DEFAULT 0" ],
198  [ 'changeField', 'ipblocks', 'ipb_address', 'text', 'ipb_address::text' ],
199  [ 'changeField', 'ipblocks', 'ipb_deleted', 'smallint', 'ipb_deleted::smallint DEFAULT 0' ],
200  [ 'changeField', 'mwuser', 'user_token', 'text', '' ],
201  [ 'changeField', 'mwuser', 'user_email_token', 'text', '' ],
202  [ 'changeField', 'objectcache', 'keyname', 'text', '' ],
203  [ 'changeField', 'oldimage', 'oi_height', 'integer', '' ],
204  [ 'changeField', 'oldimage', 'oi_metadata', 'bytea', "decode(img_metadata,'escape')" ],
205  [ 'changeField', 'oldimage', 'oi_size', 'integer', '' ],
206  [ 'changeField', 'oldimage', 'oi_width', 'integer', '' ],
207  [ 'changeField', 'page', 'page_is_redirect', 'smallint',
208  'page_is_redirect::smallint DEFAULT 0' ],
209  [ 'changeField', 'page', 'page_is_new', 'smallint', 'page_is_new::smallint DEFAULT 0' ],
210  [ 'changeField', 'querycache', 'qc_value', 'integer', '' ],
211  [ 'changeField', 'querycachetwo', 'qcc_value', 'integer', '' ],
212  [ 'changeField', 'recentchanges', 'rc_bot', 'smallint', 'rc_bot::smallint DEFAULT 0' ],
213  [ 'changeField', 'recentchanges', 'rc_deleted', 'smallint', '' ],
214  [ 'changeField', 'recentchanges', 'rc_minor', 'smallint', 'rc_minor::smallint DEFAULT 0' ],
215  [ 'changeField', 'recentchanges', 'rc_new', 'smallint', 'rc_new::smallint DEFAULT 0' ],
216  [ 'changeField', 'recentchanges', 'rc_type', 'smallint', 'rc_type::smallint DEFAULT 0' ],
217  [ 'changeField', 'recentchanges', 'rc_patrolled', 'smallint',
218  'rc_patrolled::smallint DEFAULT 0' ],
219  [ 'changeField', 'revision', 'rev_deleted', 'smallint', 'rev_deleted::smallint DEFAULT 0' ],
220  [ 'changeField', 'revision', 'rev_minor_edit', 'smallint',
221  'rev_minor_edit::smallint DEFAULT 0' ],
222  [ 'changeField', 'templatelinks', 'tl_namespace', 'smallint', 'tl_namespace::smallint' ],
223  [ 'changeField', 'user_newtalk', 'user_ip', 'text', 'host(user_ip)' ],
224  [ 'changeField', 'uploadstash', 'us_image_bits', 'smallint', '' ],
225 
226  # null changes
227  [ 'changeNullableField', 'oldimage', 'oi_bits', 'NULL' ],
228  [ 'changeNullableField', 'oldimage', 'oi_timestamp', 'NULL' ],
229  [ 'changeNullableField', 'oldimage', 'oi_major_mime', 'NULL' ],
230  [ 'changeNullableField', 'oldimage', 'oi_minor_mime', 'NULL' ],
231  [ 'changeNullableField', 'image', 'img_metadata', 'NOT NULL' ],
232  [ 'changeNullableField', 'filearchive', 'fa_metadata', 'NOT NULL' ],
233  [ 'changeNullableField', 'recentchanges', 'rc_cur_id', 'NULL' ],
234  [ 'changeNullableField', 'recentchanges', 'rc_cur_time', 'NULL' ],
235 
236  [ 'checkOiDeleted' ],
237 
238  # New indexes
239  [ 'ifNoActorTable', 'addPgIndex', 'archive', 'archive_user_text', '(ar_user_text)' ],
240  [ 'addPgIndex', 'image', 'img_sha1', '(img_sha1)' ],
241  [ 'addPgIndex', 'ipblocks', 'ipb_parent_block_id', '(ipb_parent_block_id)' ],
242  [ 'addPgIndex', 'oldimage', 'oi_sha1', '(oi_sha1)' ],
243  [ 'addPgIndex', 'page', 'page_mediawiki_title', '(page_title) WHERE page_namespace = 8' ],
244  [ 'addPgIndex', 'pagelinks', 'pagelinks_title', '(pl_title)' ],
245  [ 'addPgIndex', 'page_props', 'pp_propname_page', '(pp_propname, pp_page)' ],
246  [ 'addPgIndex', 'revision', 'rev_text_id_idx', '(rev_text_id)' ],
247  [ 'addPgIndex', 'recentchanges', 'rc_timestamp_bot', '(rc_timestamp) WHERE rc_bot = 0' ],
248  [ 'addPgIndex', 'templatelinks', 'templatelinks_from', '(tl_from)' ],
249  [ 'addPgIndex', 'watchlist', 'wl_user', '(wl_user)' ],
250  [ 'addPgIndex', 'watchlist', 'wl_user_notificationtimestamp',
251  '(wl_user, wl_notificationtimestamp)' ],
252  [ 'ifNoActorTable', 'addPgIndex', 'logging', 'logging_user_type_time',
253  '(log_user, log_type, log_timestamp)' ],
254  [ 'addPgIndex', 'logging', 'logging_page_id_time', '(log_page,log_timestamp)' ],
255  [ 'addPgIndex', 'iwlinks', 'iwl_prefix_from_title', '(iwl_prefix, iwl_from, iwl_title)' ],
256  [ 'addPgIndex', 'iwlinks', 'iwl_prefix_title_from', '(iwl_prefix, iwl_title, iwl_from)' ],
257  [ 'addPgIndex', 'job', 'job_timestamp_idx', '(job_timestamp)' ],
258  [ 'addPgIndex', 'job', 'job_sha1', '(job_sha1)' ],
259  [ 'addPgIndex', 'job', 'job_cmd_token', '(job_cmd, job_token, job_random)' ],
260  [ 'addPgIndex', 'job', 'job_cmd_token_id', '(job_cmd, job_token, job_id)' ],
261  [ 'addPgIndex', 'filearchive', 'fa_sha1', '(fa_sha1)' ],
262  [ 'ifNoActorTable', 'addPgIndex', 'logging', 'logging_user_text_type_time',
263  '(log_user_text, log_type, log_timestamp)' ],
264  [ 'ifNoActorTable', 'addPgIndex', 'logging', 'logging_user_text_time',
265  '(log_user_text, log_timestamp)' ],
266 
267  [ 'checkIndex', 'pagelink_unique', [
268  [ 'pl_from', 'int4_ops', 'btree', 0 ],
269  [ 'pl_namespace', 'int2_ops', 'btree', 0 ],
270  [ 'pl_title', 'text_ops', 'btree', 0 ],
271  ],
272  'CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)' ],
273  [ 'checkIndex', 'cl_sortkey', [
274  [ 'cl_to', 'text_ops', 'btree', 0 ],
275  [ 'cl_sortkey', 'text_ops', 'btree', 0 ],
276  [ 'cl_from', 'int4_ops', 'btree', 0 ],
277  ],
278  'CREATE INDEX cl_sortkey ON "categorylinks" ' .
279  'USING "btree" ("cl_to", "cl_sortkey", "cl_from")' ],
280  [ 'checkIndex', 'iwl_prefix_title_from', [
281  [ 'iwl_prefix', 'text_ops', 'btree', 0 ],
282  [ 'iwl_title', 'text_ops', 'btree', 0 ],
283  [ 'iwl_from', 'int4_ops', 'btree', 0 ],
284  ],
285  'CREATE INDEX iwl_prefix_title_from ON "iwlinks" ' .
286  'USING "btree" ("iwl_prefix", "iwl_title", "iwl_from")' ],
287  [ 'checkIndex', 'logging_times', [
288  [ 'log_timestamp', 'timestamptz_ops', 'btree', 0 ],
289  ],
290  'CREATE INDEX "logging_times" ON "logging" USING "btree" ("log_timestamp")' ],
291  [ 'dropPgIndex', 'oldimage', 'oi_name' ],
292  [ 'checkIndex', 'oi_name_archive_name', [
293  [ 'oi_name', 'text_ops', 'btree', 0 ],
294  [ 'oi_archive_name', 'text_ops', 'btree', 0 ],
295  ],
296  'CREATE INDEX "oi_name_archive_name" ON "oldimage" ' .
297  'USING "btree" ("oi_name", "oi_archive_name")' ],
298  [ 'checkIndex', 'oi_name_timestamp', [
299  [ 'oi_name', 'text_ops', 'btree', 0 ],
300  [ 'oi_timestamp', 'timestamptz_ops', 'btree', 0 ],
301  ],
302  'CREATE INDEX "oi_name_timestamp" ON "oldimage" ' .
303  'USING "btree" ("oi_name", "oi_timestamp")' ],
304  [ 'checkIndex', 'page_main_title', [
305  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
306  ],
307  'CREATE INDEX "page_main_title" ON "page" ' .
308  'USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 0)' ],
309  [ 'checkIndex', 'page_mediawiki_title', [
310  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
311  ],
312  'CREATE INDEX "page_mediawiki_title" ON "page" ' .
313  'USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 8)' ],
314  [ 'checkIndex', 'page_project_title', [
315  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
316  ],
317  'CREATE INDEX "page_project_title" ON "page" ' .
318  'USING "btree" ("page_title" "text_pattern_ops") ' .
319  'WHERE ("page_namespace" = 4)' ],
320  [ 'checkIndex', 'page_talk_title', [
321  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
322  ],
323  'CREATE INDEX "page_talk_title" ON "page" ' .
324  'USING "btree" ("page_title" "text_pattern_ops") ' .
325  'WHERE ("page_namespace" = 1)' ],
326  [ 'checkIndex', 'page_user_title', [
327  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
328  ],
329  'CREATE INDEX "page_user_title" ON "page" ' .
330  'USING "btree" ("page_title" "text_pattern_ops") WHERE ' .
331  '("page_namespace" = 2)' ],
332  [ 'checkIndex', 'page_utalk_title', [
333  [ 'page_title', 'text_pattern_ops', 'btree', 0 ],
334  ],
335  'CREATE INDEX "page_utalk_title" ON "page" ' .
336  'USING "btree" ("page_title" "text_pattern_ops") ' .
337  'WHERE ("page_namespace" = 3)' ],
338  [ 'checkIndex', 'ts2_page_text', [
339  [ 'textvector', 'tsvector_ops', 'gist', 0 ],
340  ],
341  'CREATE INDEX "ts2_page_text" ON "pagecontent" USING "gist" ("textvector")' ],
342  [ 'checkIndex', 'ts2_page_title', [
343  [ 'titlevector', 'tsvector_ops', 'gist', 0 ],
344  ],
345  'CREATE INDEX "ts2_page_title" ON "page" USING "gist" ("titlevector")' ],
346 
347  [ 'checkOiNameConstraint' ],
348  [ 'checkPageDeletedTrigger' ],
349  [ 'checkRevUserFkey' ],
350  [ 'dropPgIndex', 'ipblocks', 'ipb_address' ],
351  [ 'checkIndex', 'ipb_address_unique', [
352  [ 'ipb_address', 'text_ops', 'btree', 0 ],
353  [ 'ipb_user', 'int4_ops', 'btree', 0 ],
354  [ 'ipb_auto', 'int2_ops', 'btree', 0 ],
355  [ 'ipb_anon_only', 'int2_ops', 'btree', 0 ],
356  ],
357  'CREATE UNIQUE INDEX ipb_address_unique ' .
358  'ON ipblocks (ipb_address,ipb_user,ipb_auto,ipb_anon_only)' ],
359 
360  [ 'checkIwlPrefix' ],
361 
362  # All FK columns should be deferred
363  [ 'ifNoActorTable', 'changeFkeyDeferrable', 'archive', 'ar_user',
364  'mwuser(user_id) ON DELETE SET NULL' ],
365  [ 'changeFkeyDeferrable', 'categorylinks', 'cl_from', 'page(page_id) ON DELETE CASCADE' ],
366  [ 'changeFkeyDeferrable', 'externallinks', 'el_from', 'page(page_id) ON DELETE CASCADE' ],
367  [ 'changeFkeyDeferrable', 'filearchive', 'fa_deleted_user',
368  'mwuser(user_id) ON DELETE SET NULL' ],
369  [ 'ifNoActorTable', 'changeFkeyDeferrable', 'filearchive', 'fa_user',
370  'mwuser(user_id) ON DELETE SET NULL' ],
371  [ 'ifNoActorTable', 'changeFkeyDeferrable', 'image', 'img_user',
372  'mwuser(user_id) ON DELETE SET NULL' ],
373  [ 'changeFkeyDeferrable', 'imagelinks', 'il_from', 'page(page_id) ON DELETE CASCADE' ],
374  [ 'ifNoActorTable', 'changeFkeyDeferrable', 'ipblocks', 'ipb_by',
375  'mwuser(user_id) ON DELETE CASCADE' ],
376  [ 'changeFkeyDeferrable', 'ipblocks', 'ipb_user', 'mwuser(user_id) ON DELETE SET NULL' ],
377  [ 'changeFkeyDeferrable', 'ipblocks', 'ipb_parent_block_id',
378  'ipblocks(ipb_id) ON DELETE SET NULL' ],
379  [ 'changeFkeyDeferrable', 'langlinks', 'll_from', 'page(page_id) ON DELETE CASCADE' ],
380  [ 'ifNoActorTable', 'changeFkeyDeferrable', 'logging', 'log_user',
381  'mwuser(user_id) ON DELETE SET NULL' ],
382  [ 'changeFkeyDeferrable', 'oldimage', 'oi_name',
383  'image(img_name) ON DELETE CASCADE ON UPDATE CASCADE' ],
384  [ 'ifNoActorTable', 'changeFkeyDeferrable', 'oldimage', 'oi_user',
385  'mwuser(user_id) ON DELETE SET NULL' ],
386  [ 'changeFkeyDeferrable', 'pagelinks', 'pl_from', 'page(page_id) ON DELETE CASCADE' ],
387  [ 'changeFkeyDeferrable', 'page_props', 'pp_page', 'page (page_id) ON DELETE CASCADE' ],
388  [ 'changeFkeyDeferrable', 'page_restrictions', 'pr_page',
389  'page(page_id) ON DELETE CASCADE' ],
390  [ 'changeFkeyDeferrable', 'protected_titles', 'pt_user',
391  'mwuser(user_id) ON DELETE SET NULL' ],
392  [ 'ifNoActorTable', 'changeFkeyDeferrable', 'recentchanges', 'rc_user',
393  'mwuser(user_id) ON DELETE SET NULL' ],
394  [ 'changeFkeyDeferrable', 'redirect', 'rd_from', 'page(page_id) ON DELETE CASCADE' ],
395  [ 'changeFkeyDeferrable', 'revision', 'rev_page', 'page (page_id) ON DELETE CASCADE' ],
396  [ 'changeFkeyDeferrable', 'revision', 'rev_user', 'mwuser(user_id) ON DELETE RESTRICT' ],
397  [ 'changeFkeyDeferrable', 'templatelinks', 'tl_from', 'page(page_id) ON DELETE CASCADE' ],
398  [ 'changeFkeyDeferrable', 'user_groups', 'ug_user', 'mwuser(user_id) ON DELETE CASCADE' ],
399  [ 'changeFkeyDeferrable', 'user_newtalk', 'user_id', 'mwuser(user_id) ON DELETE CASCADE' ],
400  [ 'changeFkeyDeferrable', 'user_properties', 'up_user',
401  'mwuser(user_id) ON DELETE CASCADE' ],
402  [ 'changeFkeyDeferrable', 'watchlist', 'wl_user', 'mwuser(user_id) ON DELETE CASCADE' ],
403 
404  # r81574
405  [ 'addInterwikiType' ],
406  # end
407  [ 'tsearchFixes' ],
408 
409  // 1.23
410  [ 'addPgField', 'recentchanges', 'rc_source', "TEXT NOT NULL DEFAULT ''" ],
411  [ 'addPgField', 'page', 'page_links_updated', "TIMESTAMPTZ NULL" ],
412  [ 'addPgField', 'mwuser', 'user_password_expires', 'TIMESTAMPTZ NULL' ],
413  [ 'changeFieldPurgeTable', 'l10n_cache', 'lc_value', 'bytea',
414  "replace(lc_value,'\','\\\\')::bytea" ],
415  // 1.23.9
416  [ 'rebuildTextSearch' ],
417 
418  // 1.24
419  [ 'addPgField', 'page_props', 'pp_sortkey', 'float NULL' ],
420  [ 'addPgIndex', 'page_props', 'pp_propname_sortkey_page',
421  '( pp_propname, pp_sortkey, pp_page ) WHERE ( pp_sortkey IS NOT NULL )' ],
422  [ 'addPgField', 'page', 'page_lang', 'TEXT default NULL' ],
423  [ 'addPgField', 'pagelinks', 'pl_from_namespace', 'INTEGER NOT NULL DEFAULT 0' ],
424  [ 'addPgField', 'templatelinks', 'tl_from_namespace', 'INTEGER NOT NULL DEFAULT 0' ],
425  [ 'addPgField', 'imagelinks', 'il_from_namespace', 'INTEGER NOT NULL DEFAULT 0' ],
426 
427  // 1.25
428  [ 'dropTable', 'hitcounter' ],
429  [ 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ],
430  [ 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ],
431  [ 'dropFkey', 'recentchanges', 'rc_cur_id' ],
432 
433  // 1.27
434  [ 'dropTable', 'msg_resource_links' ],
435  [ 'dropTable', 'msg_resource' ],
436  [
437  'addPgField', 'watchlist', 'wl_id',
438  "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('watchlist_wl_id_seq')"
439  ],
440 
441  // 1.28
442  [ 'addPgIndex', 'recentchanges', 'rc_name_type_patrolled_timestamp',
443  '( rc_namespace, rc_type, rc_patrolled, rc_timestamp )' ],
444  [ 'addPgField', 'change_tag', 'ct_id',
445  "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('change_tag_ct_id_seq')" ],
446 
447  // 1.29
448  [ 'addPgField', 'externallinks', 'el_index_60', "BYTEA NOT NULL DEFAULT ''" ],
449  [ 'addPgIndex', 'externallinks', 'el_index_60', '( el_index_60, el_id )' ],
450  [ 'addPgIndex', 'externallinks', 'el_from_index_60', '( el_from, el_index_60, el_id )' ],
451  [ 'addPgField', 'user_groups', 'ug_expiry', "TIMESTAMPTZ NULL" ],
452  [ 'addPgIndex', 'user_groups', 'user_groups_expiry', '( ug_expiry )' ],
453 
454  // 1.30
455  [ 'addPgEnumValue', 'media_type', '3D' ],
456  [ 'setDefault', 'revision', 'rev_comment', '' ],
457  [ 'changeNullableField', 'revision', 'rev_comment', 'NOT NULL', true ],
458  [ 'setDefault', 'archive', 'ar_comment', '' ],
459  [ 'changeNullableField', 'archive', 'ar_comment', 'NOT NULL', true ],
460  [ 'addPgField', 'archive', 'ar_comment_id', 'INTEGER NOT NULL DEFAULT 0' ],
461  [ 'setDefault', 'ipblocks', 'ipb_reason', '' ],
462  [ 'addPgField', 'ipblocks', 'ipb_reason_id', 'INTEGER NOT NULL DEFAULT 0' ],
463  [ 'setDefault', 'image', 'img_description', '' ],
464  [ 'setDefault', 'oldimage', 'oi_description', '' ],
465  [ 'changeNullableField', 'oldimage', 'oi_description', 'NOT NULL', true ],
466  [ 'addPgField', 'oldimage', 'oi_description_id', 'INTEGER NOT NULL DEFAULT 0' ],
467  [ 'setDefault', 'filearchive', 'fa_deleted_reason', '' ],
468  [ 'changeNullableField', 'filearchive', 'fa_deleted_reason', 'NOT NULL', true ],
469  [ 'addPgField', 'filearchive', 'fa_deleted_reason_id', 'INTEGER NOT NULL DEFAULT 0' ],
470  [ 'setDefault', 'filearchive', 'fa_description', '' ],
471  [ 'addPgField', 'filearchive', 'fa_description_id', 'INTEGER NOT NULL DEFAULT 0' ],
472  [ 'setDefault', 'recentchanges', 'rc_comment', '' ],
473  [ 'changeNullableField', 'recentchanges', 'rc_comment', 'NOT NULL', true ],
474  [ 'addPgField', 'recentchanges', 'rc_comment_id', 'INTEGER NOT NULL DEFAULT 0' ],
475  [ 'setDefault', 'logging', 'log_comment', '' ],
476  [ 'changeNullableField', 'logging', 'log_comment', 'NOT NULL', true ],
477  [ 'addPgField', 'logging', 'log_comment_id', 'INTEGER NOT NULL DEFAULT 0' ],
478  [ 'setDefault', 'protected_titles', 'pt_reason', '' ],
479  [ 'changeNullableField', 'protected_titles', 'pt_reason', 'NOT NULL', true ],
480  [ 'addPgField', 'protected_titles', 'pt_reason_id', 'INTEGER NOT NULL DEFAULT 0' ],
481  [ 'addTable', 'comment', 'patch-comment-table.sql' ],
482  [ 'addTable', 'revision_comment_temp', 'patch-revision_comment_temp-table.sql' ],
483  // image_comment_temp is no longer needed when upgrading to MW 1.31 or newer,
484  // as it is dropped later in the update process as part of 'migrateImageCommentTemp'.
485  // File kept on disk and the updater entry here for historical purposes.
486  // [ 'addTable', 'image_comment_temp', 'patch-image_comment_temp-table.sql' ],
487 
488  // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
489  [ 'addPgField', 'image', 'img_description_id', 'INTEGER NOT NULL DEFAULT 0' ],
490 
491  [ 'migrateComments' ],
492  [ 'addIndex', 'site_stats', 'site_stats_pkey', 'patch-site_stats-pk.sql' ],
493  [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
494 
495  // 1.31
496  [ 'addTable', 'slots', 'patch-slots-table.sql' ],
497  [ 'dropPgIndex', 'slots', 'slot_role_inherited' ],
498  [ 'dropPgField', 'slots', 'slot_inherited' ],
499  [ 'addPgField', 'slots', 'slot_origin', 'INTEGER NOT NULL' ],
500  [
501  'addPgIndex',
502  'slots',
503  'slot_revision_origin_role',
504  '( slot_revision_id, slot_origin, slot_role_id )',
505  ],
506  [ 'addTable', 'content', 'patch-content-table.sql' ],
507  [ 'addTable', 'content_models', 'patch-content_models-table.sql' ],
508  [ 'addTable', 'slot_roles', 'patch-slot_roles-table.sql' ],
509  [ 'migrateArchiveText' ],
510  [ 'addTable', 'actor', 'patch-actor-table.sql' ],
511  [ 'addTable', 'revision_actor_temp', 'patch-revision_actor_temp-table.sql' ],
512  [ 'setDefault', 'revision', 'rev_user', 0 ],
513  [ 'setDefault', 'revision', 'rev_user_text', '' ],
514  [ 'setDefault', 'archive', 'ar_user', 0 ],
515  [ 'changeNullableField', 'archive', 'ar_user', 'NOT NULL', true ],
516  [ 'setDefault', 'archive', 'ar_user_text', '' ],
517  [ 'addPgField', 'archive', 'ar_actor', 'INTEGER NOT NULL DEFAULT 0' ],
518  [ 'addPgIndex', 'archive', 'archive_actor', '( ar_actor )' ],
519  [ 'setDefault', 'ipblocks', 'ipb_by', 0 ],
520  [ 'addPgField', 'ipblocks', 'ipb_by_actor', 'INTEGER NOT NULL DEFAULT 0' ],
521  [ 'setDefault', 'image', 'img_user', 0 ],
522  [ 'changeNullableField', 'image', 'img_user', 'NOT NULL', true ],
523  [ 'setDefault', 'image', 'img_user_text', '' ],
524  [ 'addPgField', 'image', 'img_actor', 'INTEGER NOT NULL DEFAULT 0' ],
525  [ 'setDefault', 'oldimage', 'oi_user', 0 ],
526  [ 'changeNullableField', 'oldimage', 'oi_user', 'NOT NULL', true ],
527  [ 'setDefault', 'oldimage', 'oi_user_text', '' ],
528  [ 'addPgField', 'oldimage', 'oi_actor', 'INTEGER NOT NULL DEFAULT 0' ],
529  [ 'setDefault', 'filearchive', 'fa_user', 0 ],
530  [ 'changeNullableField', 'filearchive', 'fa_user', 'NOT NULL', true ],
531  [ 'setDefault', 'filearchive', 'fa_user_text', '' ],
532  [ 'addPgField', 'filearchive', 'fa_actor', 'INTEGER NOT NULL DEFAULT 0' ],
533  [ 'setDefault', 'recentchanges', 'rc_user', 0 ],
534  [ 'changeNullableField', 'recentchanges', 'rc_user', 'NOT NULL', true ],
535  [ 'setDefault', 'recentchanges', 'rc_user_text', '' ],
536  [ 'addPgField', 'recentchanges', 'rc_actor', 'INTEGER NOT NULL DEFAULT 0' ],
537  [ 'setDefault', 'logging', 'log_user', 0 ],
538  [ 'changeNullableField', 'logging', 'log_user', 'NOT NULL', true ],
539  [ 'addPgField', 'logging', 'log_actor', 'INTEGER NOT NULL DEFAULT 0' ],
540  [ 'addPgIndex', 'logging', 'logging_actor_time_backwards', '( log_timestamp, log_actor )' ],
541  [ 'addPgIndex', 'logging', 'logging_actor_type_time', '( log_actor, log_type, log_timestamp )' ],
542  [ 'addPgIndex', 'logging', 'logging_actor_time', '( log_actor, log_timestamp )' ],
543  [ 'migrateActors' ],
544  [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
545  [ 'populateArchiveRevId' ],
546  [ 'dropPgIndex', 'recentchanges', 'rc_namespace_title' ],
547  [
548  'addPgIndex',
549  'recentchanges',
550  'rc_namespace_title_timestamp', '( rc_namespace, rc_title, rc_timestamp )'
551  ],
552  [ 'setSequenceOwner', 'mwuser', 'user_id', 'user_user_id_seq' ],
553  [ 'setSequenceOwner', 'actor', 'actor_id', 'actor_actor_id_seq' ],
554  [ 'setSequenceOwner', 'page', 'page_id', 'page_page_id_seq' ],
555  [ 'setSequenceOwner', 'revision', 'rev_id', 'revision_rev_id_seq' ],
556  [ 'setSequenceOwner', 'ip_changes', 'ipc_rev_id', 'ip_changes_ipc_rev_id_seq' ],
557  [ 'setSequenceOwner', 'pagecontent', 'old_id', 'text_old_id_seq' ],
558  [ 'setSequenceOwner', 'comment', 'comment_id', 'comment_comment_id_seq' ],
559  [ 'setSequenceOwner', 'page_restrictions', 'pr_id', 'page_restrictions_pr_id_seq' ],
560  [ 'setSequenceOwner', 'archive', 'ar_id', 'archive_ar_id_seq' ],
561  [ 'setSequenceOwner', 'content', 'content_id', 'content_content_id_seq' ],
562  [ 'setSequenceOwner', 'slot_roles', 'role_id', 'slot_roles_role_id_seq' ],
563  [ 'setSequenceOwner', 'content_models', 'model_id', 'content_models_model_id_seq' ],
564  [ 'setSequenceOwner', 'externallinks', 'el_id', 'externallinks_el_id_seq' ],
565  [ 'setSequenceOwner', 'ipblocks', 'ipb_id', 'ipblocks_ipb_id_seq' ],
566  [ 'setSequenceOwner', 'filearchive', 'fa_id', 'filearchive_fa_id_seq' ],
567  [ 'setSequenceOwner', 'uploadstash', 'us_id', 'uploadstash_us_id_seq' ],
568  [ 'setSequenceOwner', 'recentchanges', 'rc_id', 'recentchanges_rc_id_seq' ],
569  [ 'setSequenceOwner', 'watchlist', 'wl_id', 'watchlist_wl_id_seq' ],
570  [ 'setSequenceOwner', 'logging', 'log_id', 'logging_log_id_seq' ],
571  [ 'setSequenceOwner', 'job', 'job_id', 'job_job_id_seq' ],
572  [ 'setSequenceOwner', 'category', 'cat_id', 'category_cat_id_seq' ],
573  [ 'setSequenceOwner', 'change_tag', 'ct_id', 'change_tag_ct_id_seq' ],
574  [ 'setSequenceOwner', 'sites', 'site_id', 'sites_site_id_seq' ],
575 
576  // 1.32
577  [ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
578  [ 'populateExternallinksIndex60' ],
579  [ 'dropDefault', 'externallinks', 'el_index_60' ],
580  [ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
581  [ 'addPgField', 'change_tag', 'ct_tag_id', 'INTEGER NULL' ],
582  [
583  'addPgIndex',
584  'change_tag',
585  'change_tag_tag_id_id',
586  '( ct_tag_id, ct_rc_id, ct_rev_id, ct_log_id )'
587  ],
588  [ 'addPgIndex', 'archive', 'ar_revid_uniq', '(ar_rev_id)', 'unique' ],
589  [ 'dropPgIndex', 'archive', 'ar_revid' ], // Probably doesn't exist, but do it anyway.
590  [ 'populateContentTables' ],
591  [ 'addPgIndex', 'logging', 'log_type_action', '( log_type, log_action, log_timestamp )' ],
592  [ 'dropPgIndex', 'page_props', 'page_props_propname' ],
593  [ 'addIndex', 'interwiki', 'interwiki_pkey', 'patch-interwiki-pk.sql' ],
594  [ 'addIndex', 'protected_titles', 'protected_titles_pkey', 'patch-protected_titles-pk.sql' ],
595  [ 'addIndex', 'site_identifiers', 'site_identifiers_pkey', 'patch-site_identifiers-pk.sql' ],
596  [ 'addPgIndex', 'recentchanges', 'rc_this_oldid', '(rc_this_oldid)' ],
597  [ 'dropTable', 'transcache' ],
598  [ 'runMaintenance', PopulateChangeTagDef::class, 'maintenance/populateChangeTagDef.php' ],
599  [ 'addIndex', 'change_tag', 'change_tag_rc_tag_id',
600  'patch-change_tag-change_tag_rc_tag_id.sql' ],
601  [ 'addPgField', 'ipblocks', 'ipb_sitewide', 'SMALLINT NOT NULL DEFAULT 1' ],
602  [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
603  [ 'migrateImageCommentTemp' ],
604  [ 'dropPgField', 'category', 'cat_hidden' ],
605  [ 'dropPgField', 'site_stats', 'ss_admins' ],
606  [ 'dropPgField', 'recentchanges', 'rc_cur_time' ],
607 
608  // 1.33
609  [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
610  [ 'dropTable', 'valid_tag' ],
611  [ 'dropTable', 'tag_summary' ],
612  [ 'dropPgField', 'archive', 'ar_comment' ],
613  [ 'dropDefault', 'archive', 'ar_comment_id' ],
614  [ 'dropPgField', 'ipblocks', 'ipb_reason' ],
615  [ 'dropDefault', 'ipblocks', 'ipb_reason_id' ],
616  [ 'dropPgField', 'image', 'img_description' ],
617  [ 'dropDefault', 'image', 'img_description_id' ],
618  [ 'dropPgField', 'oldimage', 'oi_description' ],
619  [ 'dropDefault', 'oldimage', 'oi_description_id' ],
620  [ 'dropPgField', 'filearchive', 'fa_deleted_reason' ],
621  [ 'dropDefault', 'filearchive', 'fa_deleted_reason_id' ],
622  [ 'dropPgField', 'filearchive', 'fa_description' ],
623  [ 'dropDefault', 'filearchive', 'fa_description_id' ],
624  [ 'dropPgField', 'recentchanges', 'rc_comment' ],
625  [ 'dropDefault', 'recentchanges', 'rc_comment_id' ],
626  [ 'dropPgField', 'logging', 'log_comment' ],
627  [ 'dropDefault', 'logging', 'log_comment_id' ],
628  [ 'dropPgField', 'protected_titles', 'pt_reason' ],
629  [ 'dropDefault', 'protected_titles', 'pt_reason_id' ],
630 
631  // 1.34
632  [ 'dropPgIndex', 'archive', 'archive_user_text' ],
633  [ 'dropPgField', 'archive', 'ar_user' ],
634  [ 'dropPgField', 'archive', 'ar_user_text' ],
635  [ 'dropDefault', 'archive', 'ar_actor' ],
636  [ 'dropPgField', 'ipblocks', 'ipb_by' ],
637  [ 'dropPgField', 'ipblocks', 'ipb_by_text' ],
638  [ 'dropDefault', 'ipblocks', 'ipb_by_actor' ],
639  [ 'dropPgField', 'image', 'img_user' ],
640  [ 'dropPgField', 'image', 'img_user_text' ],
641  [ 'dropDefault', 'image', 'img_actor' ],
642  [ 'dropPgField', 'oldimage', 'oi_user' ],
643  [ 'dropPgField', 'oldimage', 'oi_user_text' ],
644  [ 'dropDefault', 'oldimage', 'oi_actor' ],
645  [ 'dropPgField', 'filearchive', 'fa_user' ],
646  [ 'dropPgField', 'filearchive', 'fa_user_text' ],
647  [ 'dropDefault', 'filearchive', 'fa_actor' ],
648  [ 'dropPgField', 'recentchanges', 'rc_user' ],
649  [ 'dropPgField', 'recentchanges', 'rc_user_text' ],
650  [ 'dropDefault', 'recentchanges', 'rc_actor' ],
651  [ 'dropPgIndex', 'logging', 'logging_user_time' ],
652  [ 'dropPgIndex', 'logging', 'logging_user_type_time' ],
653  [ 'dropPgIndex', 'logging', 'logging_user_text_type_time' ],
654  [ 'dropPgIndex', 'logging', 'logging_user_text_time' ],
655  [ 'dropPgField', 'logging', 'log_user' ],
656  [ 'dropPgField', 'logging', 'log_user_text' ],
657  [ 'dropDefault', 'logging', 'log_actor' ],
658 
659  // 1.35
660  [ 'addIndex', 'redirect', 'redirect_pkey', 'patch-redirect-pk.sql' ],
661  [ 'addTable', 'watchlist_expiry', 'patch-watchlist_expiry.sql' ],
662  [ 'setSequenceOwner', 'watchlist_expiry', 'we_item', 'watchlist_expiry_we_item_seq' ],
663  ];
664  }
665 
666  protected function getOldGlobalUpdates() {
667  global $wgExtNewTables, $wgExtPGNewFields, $wgExtPGAlteredFields, $wgExtNewIndexes;
668 
669  $updates = [];
670 
671  # Add missing extension tables
672  foreach ( $wgExtNewTables as $tableRecord ) {
673  $updates[] = [
674  'addTable', $tableRecord[0], $tableRecord[1], true
675  ];
676  }
677 
678  # Add missing extension fields
679  foreach ( $wgExtPGNewFields as $fieldRecord ) {
680  $updates[] = [
681  'addPgField', $fieldRecord[0], $fieldRecord[1],
682  $fieldRecord[2]
683  ];
684  }
685 
686  # Change altered columns
687  foreach ( $wgExtPGAlteredFields as $fieldRecord ) {
688  $updates[] = [
689  'changeField', $fieldRecord[0], $fieldRecord[1],
690  $fieldRecord[2]
691  ];
692  }
693 
694  # Add missing extension indexes
695  foreach ( $wgExtNewIndexes as $fieldRecord ) {
696  $updates[] = [
697  'addPgExtIndex', $fieldRecord[0], $fieldRecord[1],
698  $fieldRecord[2]
699  ];
700  }
701 
702  return $updates;
703  }
704 
705  protected function describeTable( $table ) {
706  $q = <<<END
707 SELECT attname, attnum FROM pg_namespace, pg_class, pg_attribute
708  WHERE pg_class.relnamespace = pg_namespace.oid
709  AND attrelid=pg_class.oid AND attnum > 0
710  AND relname=%s AND nspname=%s
711 END;
712  $res = $this->db->query( sprintf( $q,
713  $this->db->addQuotes( $table ),
714  $this->db->addQuotes( $this->db->getCoreSchema() ) ) );
715  if ( !$res ) {
716  return null;
717  }
718 
719  $cols = [];
720  foreach ( $res as $r ) {
721  $cols[] = [
722  "name" => $r[0],
723  "ord" => $r[1],
724  ];
725  }
726 
727  return $cols;
728  }
729 
730  function describeIndex( $idx ) {
731  // first fetch the key (which is a list of columns ords) and
732  // the table the index applies to (an oid)
733  $q = <<<END
734 SELECT indkey, indrelid FROM pg_namespace, pg_class, pg_index
735  WHERE nspname=%s
736  AND pg_class.relnamespace = pg_namespace.oid
737  AND relname=%s
738  AND indexrelid=pg_class.oid
739 END;
740  $res = $this->db->query(
741  sprintf(
742  $q,
743  $this->db->addQuotes( $this->db->getCoreSchema() ),
744  $this->db->addQuotes( $idx )
745  )
746  );
747  if ( !$res ) {
748  return null;
749  }
750  $r = $this->db->fetchRow( $res );
751  if ( !$r ) {
752  return null;
753  }
754 
755  $indkey = $r[0];
756  $relid = intval( $r[1] );
757  $indkeys = explode( ' ', $indkey );
758 
759  $colnames = [];
760  foreach ( $indkeys as $rid ) {
761  $query = <<<END
762 SELECT attname FROM pg_class, pg_attribute
763  WHERE attrelid=$relid
764  AND attnum=%d
765  AND attrelid=pg_class.oid
766 END;
767  $r2 = $this->db->query( sprintf( $query, $rid ) );
768  if ( !$r2 ) {
769  return null;
770  }
771  $row2 = $this->db->fetchRow( $r2 );
772  if ( !$row2 ) {
773  return null;
774  }
775  $colnames[] = $row2[0];
776  }
777 
778  return $colnames;
779  }
780 
781  function fkeyDeltype( $fkey ) {
782  $q = <<<END
783 SELECT confdeltype FROM pg_constraint, pg_namespace
784  WHERE connamespace=pg_namespace.oid
785  AND nspname=%s
786  AND conname=%s;
787 END;
788  $r = $this->db->query(
789  sprintf(
790  $q,
791  $this->db->addQuotes( $this->db->getCoreSchema() ),
792  $this->db->addQuotes( $fkey )
793  )
794  );
795  $row = $this->db->fetchRow( $r );
796  if ( !$row ) {
797  return null;
798  }
799 
800  return $row[0];
801  }
802 
803  function ruleDef( $table, $rule ) {
804  $q = <<<END
805 SELECT definition FROM pg_rules
806  WHERE schemaname = %s
807  AND tablename = %s
808  AND rulename = %s
809 END;
810  $r = $this->db->query(
811  sprintf(
812  $q,
813  $this->db->addQuotes( $this->db->getCoreSchema() ),
814  $this->db->addQuotes( $table ),
815  $this->db->addQuotes( $rule )
816  )
817  );
818  $row = $this->db->fetchRow( $r );
819  if ( !$row ) {
820  return null;
821  }
822  $d = $row[0];
823 
824  return $d;
825  }
826 
827  protected function addSequence( $table, $pkey, $ns ) {
828  if ( !$this->db->sequenceExists( $ns ) ) {
829  $this->output( "Creating sequence $ns\n" );
830  if ( $pkey !== false ) {
831  $this->db->query( "CREATE SEQUENCE $ns OWNED BY $table.$pkey" );
832  $this->setDefault( $table, $pkey, '"nextval"(\'"' . $ns . '"\'::"regclass")' );
833  } else {
834  $this->db->query( "CREATE SEQUENCE $ns" );
835  }
836  }
837  }
838 
839  protected function dropSequence( $table, $ns ) {
840  if ( $this->db->sequenceExists( $ns ) ) {
841  $this->output( "Dropping sequence $ns\n" );
842  $this->db->query( "DROP SEQUENCE $ns CASCADE" );
843  }
844  }
845 
846  protected function renameSequence( $old, $new ) {
847  if ( $this->db->sequenceExists( $new ) ) {
848  $this->output( "...sequence $new already exists.\n" );
849 
850  return;
851  }
852  if ( $this->db->sequenceExists( $old ) ) {
853  $this->output( "Renaming sequence $old to $new\n" );
854  $this->db->query( "ALTER SEQUENCE $old RENAME TO $new" );
855  }
856  }
857 
858  protected function setSequenceOwner( $table, $pkey, $seq ) {
859  if ( $this->db->sequenceExists( $seq ) ) {
860  $this->output( "Setting sequence $seq owner to $table.$pkey\n" );
861  $this->db->query( "ALTER SEQUENCE $seq OWNED BY $table.$pkey" );
862  }
863  }
864 
865  protected function renameTable( $old, $new, $patch = false ) {
866  if ( $this->db->tableExists( $old ) ) {
867  $this->output( "Renaming table $old to $new\n" );
868  $old = $this->db->realTableName( $old, "quoted" );
869  $new = $this->db->realTableName( $new, "quoted" );
870  $this->db->query( "ALTER TABLE $old RENAME TO $new" );
871  if ( $patch !== false ) {
872  $this->applyPatch( $patch );
873  }
874  }
875  }
876 
877  protected function renameIndex(
878  $table, $old, $new, $skipBothIndexExistWarning = false, $a = false, $b = false
879  ) {
880  // First requirement: the table must exist
881  if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
882  $this->output( "...skipping: '$table' table doesn't exist yet.\n" );
883 
884  return true;
885  }
886 
887  // Second requirement: the new index must be missing
888  if ( $this->db->indexExists( $table, $new, __METHOD__ ) ) {
889  $this->output( "...index $new already set on $table table.\n" );
890  if ( !$skipBothIndexExistWarning
891  && $this->db->indexExists( $table, $old, __METHOD__ )
892  ) {
893  $this->output( "...WARNING: $old still exists, despite it has been " .
894  "renamed into $new (which also exists).\n" .
895  " $old should be manually removed if not needed anymore.\n" );
896  }
897 
898  return true;
899  }
900 
901  // Third requirement: the old index must exist
902  if ( !$this->db->indexExists( $table, $old, __METHOD__ ) ) {
903  $this->output( "...skipping: index $old doesn't exist.\n" );
904 
905  return true;
906  }
907 
908  $this->db->query( "ALTER INDEX $old RENAME TO $new" );
909  return true;
910  }
911 
912  protected function dropPgField( $table, $field ) {
913  $fi = $this->db->fieldInfo( $table, $field );
914  if ( $fi === null ) {
915  $this->output( "...$table table does not contain $field field.\n" );
916 
917  return;
918  } else {
919  $this->output( "Dropping column '$table.$field'\n" );
920  $this->db->query( "ALTER TABLE $table DROP COLUMN $field" );
921  }
922  }
923 
924  protected function addPgField( $table, $field, $type ) {
925  $fi = $this->db->fieldInfo( $table, $field );
926  if ( $fi !== null ) {
927  $this->output( "...column '$table.$field' already exists\n" );
928 
929  return;
930  } else {
931  $this->output( "Adding column '$table.$field'\n" );
932  $this->db->query( "ALTER TABLE $table ADD $field $type" );
933  }
934  }
935 
936  protected function changeField( $table, $field, $newtype, $default ) {
937  $fi = $this->db->fieldInfo( $table, $field );
938  if ( $fi === null ) {
939  $this->output( "...ERROR: expected column $table.$field to exist\n" );
940  exit( 1 );
941  }
942 
943  if ( $fi->type() === $newtype ) {
944  $this->output( "...column '$table.$field' is already of type '$newtype'\n" );
945  } else {
946  $this->output( "Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
947  $sql = "ALTER TABLE $table ALTER $field TYPE $newtype";
948  if ( strlen( $default ) ) {
949  $res = [];
950  if ( preg_match( '/DEFAULT (.+)/', $default, $res ) ) {
951  $sqldef = "ALTER TABLE $table ALTER $field SET DEFAULT $res[1]";
952  $this->db->query( $sqldef );
953  $default = preg_replace( '/\s*DEFAULT .+/', '', $default );
954  }
955  $sql .= " USING $default";
956  }
957  $this->db->query( $sql );
958  }
959  }
960 
961  protected function changeFieldPurgeTable( $table, $field, $newtype, $default ) {
962  # # For a cache table, empty it if the field needs to be changed, because the old contents
963  # # may be corrupted. If the column is already the desired type, refrain from purging.
964  $fi = $this->db->fieldInfo( $table, $field );
965  if ( $fi === null ) {
966  $this->output( "...ERROR: expected column $table.$field to exist\n" );
967  exit( 1 );
968  }
969 
970  if ( $fi->type() === $newtype ) {
971  $this->output( "...column '$table.$field' is already of type '$newtype'\n" );
972  } else {
973  $this->output( "Purging data from cache table '$table'\n" );
974  $this->db->query( "DELETE from $table" );
975  $this->output( "Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
976  $sql = "ALTER TABLE $table ALTER $field TYPE $newtype";
977  if ( strlen( $default ) ) {
978  $res = [];
979  if ( preg_match( '/DEFAULT (.+)/', $default, $res ) ) {
980  $sqldef = "ALTER TABLE $table ALTER $field SET DEFAULT $res[1]";
981  $this->db->query( $sqldef );
982  $default = preg_replace( '/\s*DEFAULT .+/', '', $default );
983  }
984  $sql .= " USING $default";
985  }
986  $this->db->query( $sql );
987  }
988  }
989 
990  protected function setDefault( $table, $field, $default ) {
991  $info = $this->db->fieldInfo( $table, $field );
992  if ( $info && $info->defaultValue() !== $default ) {
993  $this->output( "Changing '$table.$field' default value\n" );
994  $this->db->query( "ALTER TABLE $table ALTER $field SET DEFAULT "
995  . $this->db->addQuotes( $default ) );
996  }
997  }
998 
1005  protected function dropDefault( $table, $field ) {
1006  $info = $this->db->fieldInfo( $table, $field );
1007  if ( $info->defaultValue() !== false ) {
1008  $this->output( "Removing '$table.$field' default value\n" );
1009  $this->db->query( "ALTER TABLE $table ALTER $field DROP DEFAULT" );
1010  }
1011  }
1012 
1013  protected function changeNullableField( $table, $field, $null, $update = false ) {
1014  $fi = $this->db->fieldInfo( $table, $field );
1015  if ( $fi === null ) {
1016  return;
1017  }
1018  if ( $fi->isNullable() ) {
1019  # # It's NULL - does it need to be NOT NULL?
1020  if ( $null === 'NOT NULL' ) {
1021  $this->output( "Changing '$table.$field' to not allow NULLs\n" );
1022  if ( $update ) {
1023  $this->db->query( "UPDATE $table SET $field = DEFAULT WHERE $field IS NULL" );
1024  }
1025  $this->db->query( "ALTER TABLE $table ALTER $field SET NOT NULL" );
1026  } else {
1027  $this->output( "...column '$table.$field' is already set as NULL\n" );
1028  }
1029  } else {
1030  # # It's NOT NULL - does it need to be NULL?
1031  if ( $null === 'NULL' ) {
1032  $this->output( "Changing '$table.$field' to allow NULLs\n" );
1033  $this->db->query( "ALTER TABLE $table ALTER $field DROP NOT NULL" );
1034  } else {
1035  $this->output( "...column '$table.$field' is already set as NOT NULL\n" );
1036  }
1037  }
1038  }
1039 
1040  public function addPgIndex( $table, $index, $type, $unique = false ) {
1041  if ( $this->db->indexExists( $table, $index ) ) {
1042  $this->output( "...index '$index' on table '$table' already exists\n" );
1043  } else {
1044  $this->output( "Creating index '$index' on table '$table' $type\n" );
1045  $unique = $unique ? 'UNIQUE' : '';
1046  $this->db->query( "CREATE $unique INDEX $index ON $table $type" );
1047  }
1048  }
1049 
1050  public function addPgExtIndex( $table, $index, $type ) {
1051  if ( $this->db->indexExists( $table, $index ) ) {
1052  $this->output( "...index '$index' on table '$table' already exists\n" );
1053  } elseif ( preg_match( '/^\(/', $type ) ) {
1054  $this->output( "Creating index '$index' on table '$table'\n" );
1055  $this->db->query( "CREATE INDEX $index ON $table $type" );
1056  } else {
1057  $this->applyPatch( $type, true, "Creating index '$index' on table '$table'" );
1058  }
1059  }
1060 
1067  public function addPgEnumValue( $type, $value ) {
1068  $row = $this->db->selectRow(
1069  [
1070  't' => 'pg_catalog.pg_type',
1071  'n' => 'pg_catalog.pg_namespace',
1072  'e' => 'pg_catalog.pg_enum',
1073  ],
1074  [ 't.typname', 't.typtype', 'e.enumlabel' ],
1075  [
1076  't.typname' => $type,
1077  'n.nspname' => $this->db->getCoreSchema(),
1078  ],
1079  __METHOD__,
1080  [],
1081  [
1082  'n' => [ 'JOIN', 't.typnamespace = n.oid' ],
1083  'e' => [ 'LEFT JOIN', [ 'e.enumtypid = t.oid', 'e.enumlabel' => $value ] ],
1084  ]
1085  );
1086 
1087  if ( !$row ) {
1088  $this->output( "...Type $type does not exist, skipping modify enum.\n" );
1089  } elseif ( $row->typtype !== 'e' ) {
1090  $this->output( "...Type $type does not seem to be an enum, skipping modify enum.\n" );
1091  } elseif ( $row->enumlabel === $value ) {
1092  $this->output( "...Enum type $type already contains value '$value'.\n" );
1093  } else {
1094  $this->output( "...Adding value '$value' to enum type $type.\n" );
1095  $etype = $this->db->addIdentifierQuotes( $type );
1096  $evalue = $this->db->addQuotes( $value );
1097  $this->db->query( "ALTER TYPE $etype ADD VALUE $evalue" );
1098  }
1099  }
1100 
1101  protected function dropFkey( $table, $field ) {
1102  $fi = $this->db->fieldInfo( $table, $field );
1103  if ( $fi === null ) {
1104  $this->output( "WARNING! Column '$table.$field' does not exist but it should! " .
1105  "Please report this.\n" );
1106  return;
1107  }
1108  $conname = $fi->conname();
1109  if ( $fi->conname() ) {
1110  $this->output( "Dropping foreign key constraint on '$table.$field'\n" );
1111  $conclause = "CONSTRAINT \"$conname\"";
1112  $command = "ALTER TABLE $table DROP CONSTRAINT $conname";
1113  $this->db->query( $command );
1114  } else {
1115  $this->output( "...foreign key constraint on '$table.$field' already does not exist\n" );
1116  }
1117  }
1118 
1119  protected function changeFkeyDeferrable( $table, $field, $clause ) {
1120  $fi = $this->db->fieldInfo( $table, $field );
1121  if ( $fi === null ) {
1122  $this->output( "WARNING! Column '$table.$field' does not exist but it should! " .
1123  "Please report this.\n" );
1124 
1125  return;
1126  }
1127  if ( $fi->is_deferred() && $fi->is_deferrable() ) {
1128  return;
1129  }
1130  $this->output( "Altering column '$table.$field' to be DEFERRABLE INITIALLY DEFERRED\n" );
1131  $conname = $fi->conname();
1132  if ( $fi->conname() ) {
1133  $conclause = "CONSTRAINT \"$conname\"";
1134  $command = "ALTER TABLE $table DROP CONSTRAINT $conname";
1135  $this->db->query( $command );
1136  } else {
1137  $this->output( "Column '$table.$field' does not have a foreign key " .
1138  "constraint, will be added\n" );
1139  $conclause = "";
1140  }
1141  $command =
1142  "ALTER TABLE $table ADD $conclause " .
1143  "FOREIGN KEY ($field) REFERENCES $clause DEFERRABLE INITIALLY DEFERRED";
1144  $this->db->query( $command );
1145  }
1146 
1147  protected function convertArchive2() {
1148  if ( $this->db->tableExists( "archive2" ) ) {
1149  if ( $this->db->ruleExists( 'archive', 'archive_insert' ) ) {
1150  $this->output( "Dropping rule 'archive_insert'\n" );
1151  $this->db->query( 'DROP RULE archive_insert ON archive' );
1152  }
1153  if ( $this->db->ruleExists( 'archive', 'archive_delete' ) ) {
1154  $this->output( "Dropping rule 'archive_delete'\n" );
1155  $this->db->query( 'DROP RULE archive_delete ON archive' );
1156  }
1157  $this->applyPatch(
1158  'patch-remove-archive2.sql',
1159  false,
1160  "Converting 'archive2' back to normal archive table"
1161  );
1162  } else {
1163  $this->output( "...obsolete table 'archive2' does not exist\n" );
1164  }
1165  }
1166 
1167  protected function checkOiDeleted() {
1168  if ( $this->db->fieldInfo( 'oldimage', 'oi_deleted' )->type() !== 'smallint' ) {
1169  $this->output( "Changing 'oldimage.oi_deleted' to type 'smallint'\n" );
1170  $this->db->query( "ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT" );
1171  $this->db->query(
1172  "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)" );
1173  $this->db->query( "ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0" );
1174  } else {
1175  $this->output( "...column 'oldimage.oi_deleted' is already of type 'smallint'\n" );
1176  }
1177  }
1178 
1179  protected function checkOiNameConstraint() {
1180  if ( $this->db->hasConstraint( "oldimage_oi_name_fkey_cascaded" ) ) {
1181  $this->output( "...table 'oldimage' has correct cascading delete/update " .
1182  "foreign key to image\n" );
1183  } else {
1184  if ( $this->db->hasConstraint( "oldimage_oi_name_fkey" ) ) {
1185  $this->db->query(
1186  "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey" );
1187  }
1188  if ( $this->db->hasConstraint( "oldimage_oi_name_fkey_cascade" ) ) {
1189  $this->db->query(
1190  "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey_cascade" );
1191  }
1192  $this->output( "Making foreign key on table 'oldimage' (to image) a cascade delete/update\n" );
1193  $this->db->query(
1194  "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascaded " .
1195  "FOREIGN KEY (oi_name) REFERENCES image(img_name) " .
1196  "ON DELETE CASCADE ON UPDATE CASCADE" );
1197  }
1198  }
1199 
1200  protected function checkPageDeletedTrigger() {
1201  if ( !$this->db->triggerExists( 'page', 'page_deleted' ) ) {
1202  $this->applyPatch(
1203  'patch-page_deleted.sql',
1204  false,
1205  "Adding function and trigger 'page_deleted' to table 'page'"
1206  );
1207  } else {
1208  $this->output( "...table 'page' has 'page_deleted' trigger\n" );
1209  }
1210  }
1211 
1212  protected function dropPgIndex( $table, $index ) {
1213  if ( $this->db->indexExists( $table, $index ) ) {
1214  $this->output( "Dropping obsolete index '$index'\n" );
1215  $this->db->query( "DROP INDEX \"" . $index . "\"" );
1216  }
1217  }
1218 
1219  protected function checkIndex( $index, $should_be, $good_def ) {
1220  $pu = $this->db->indexAttributes( $index );
1221  if ( !empty( $pu ) && $pu != $should_be ) {
1222  $this->output( "Dropping obsolete version of index '$index'\n" );
1223  $this->db->query( "DROP INDEX \"" . $index . "\"" );
1224  $pu = [];
1225  } else {
1226  $this->output( "...no need to drop index '$index'\n" );
1227  }
1228 
1229  if ( empty( $pu ) ) {
1230  $this->output( "Creating index '$index'\n" );
1231  $this->db->query( $good_def );
1232  } else {
1233  $this->output( "...index '$index' exists\n" );
1234  }
1235  }
1236 
1237  protected function checkRevUserFkey() {
1238  if ( $this->fkeyDeltype( 'revision_rev_user_fkey' ) == 'r' ) {
1239  $this->output( "...constraint 'revision_rev_user_fkey' is ON DELETE RESTRICT\n" );
1240  } else {
1241  $this->applyPatch(
1242  'patch-revision_rev_user_fkey.sql',
1243  false,
1244  "Changing constraint 'revision_rev_user_fkey' to ON DELETE RESTRICT"
1245  );
1246  }
1247  }
1248 
1249  protected function checkIwlPrefix() {
1250  if ( $this->db->indexExists( 'iwlinks', 'iwl_prefix' ) ) {
1251  $this->applyPatch(
1252  'patch-rename-iwl_prefix.sql',
1253  false,
1254  "Replacing index 'iwl_prefix' with 'iwl_prefix_title_from'"
1255  );
1256  }
1257  }
1258 
1259  protected function addInterwikiType() {
1260  $this->applyPatch( 'patch-add_interwiki.sql', false, "Refreshing add_interwiki()" );
1261  }
1262 
1263  protected function tsearchFixes() {
1264  # Tweak the page_title tsearch2 trigger to filter out slashes
1265  # This is create or replace, so harmless to call if not needed
1266  $this->applyPatch( 'patch-ts2pagetitle.sql', false, "Refreshing ts2_page_title()" );
1267 
1268  # If the server is 8.3 or higher, rewrite the tsearch2 triggers
1269  # in case they have the old 'default' versions
1270  # Gather version numbers in case we need them
1271  if ( $this->db->getServerVersion() >= 8.3 ) {
1272  $this->applyPatch( 'patch-tsearch2funcs.sql', false, "Rewriting tsearch2 triggers" );
1273  }
1274  }
1275 
1276  protected function rebuildTextSearch() {
1277  if ( $this->updateRowExists( 'patch-textsearch_bug66650.sql' ) ) {
1278  $this->output( "...T68650 already fixed or not applicable.\n" );
1279  return;
1280  }
1281  $this->applyPatch( 'patch-textsearch_bug66650.sql', false,
1282  'Rebuilding text search for T68650' );
1283  }
1284 }
DatabaseUpdater\output
output( $str)
Output some text.
Definition: DatabaseUpdater.php:221
PostgresUpdater\rebuildTextSearch
rebuildTextSearch()
Definition: PostgresUpdater.php:1276
PostgresUpdater\renameIndex
renameIndex( $table, $old, $new, $skipBothIndexExistWarning=false, $a=false, $b=false)
Rename an index from an existing table.
Definition: PostgresUpdater.php:877
PostgresUpdater\checkOiNameConstraint
checkOiNameConstraint()
Definition: PostgresUpdater.php:1179
PostgresUpdater\changeNullableField
changeNullableField( $table, $field, $null, $update=false)
Definition: PostgresUpdater.php:1013
PostgresUpdater\getCoreUpdateList
getCoreUpdateList()
Definition: PostgresUpdater.php:44
PostgresUpdater\setDefault
setDefault( $table, $field, $default)
Definition: PostgresUpdater.php:990
PostgresUpdater\addPgEnumValue
addPgEnumValue( $type, $value)
Add a value to an existing PostgreSQL enum type.
Definition: PostgresUpdater.php:1067
DatabaseUpdater\applyPatch
applyPatch( $path, $isFullPath=false, $msg=null)
Applies a SQL patch.
Definition: DatabaseUpdater.php:673
DatabaseUpdater
Class for handling database updates.
Definition: DatabaseUpdater.php:36
PostgresUpdater\convertArchive2
convertArchive2()
Definition: PostgresUpdater.php:1147
true
return true
Definition: router.php:92
PostgresUpdater\dropFkey
dropFkey( $table, $field)
Definition: PostgresUpdater.php:1101
PostgresUpdater\checkPageDeletedTrigger
checkPageDeletedTrigger()
Definition: PostgresUpdater.php:1200
PostgresUpdater\describeIndex
describeIndex( $idx)
Definition: PostgresUpdater.php:730
PostgresUpdater\$db
DatabasePostgres $db
Definition: PostgresUpdater.php:37
PostgresUpdater\renameTable
renameTable( $old, $new, $patch=false)
Definition: PostgresUpdater.php:865
PostgresUpdater\fkeyDeltype
fkeyDeltype( $fkey)
Definition: PostgresUpdater.php:781
Wikimedia\Rdbms\DatabasePostgres
Definition: DatabasePostgres.php:33
PostgresUpdater\checkIwlPrefix
checkIwlPrefix()
Definition: PostgresUpdater.php:1249
$res
$res
Definition: testCompression.php:54
PostgresUpdater\changeField
changeField( $table, $field, $newtype, $default)
Definition: PostgresUpdater.php:936
DatabaseUpdater\$updates
array $updates
Array of updates to perform on the database.
Definition: DatabaseUpdater.php:44
PostgresUpdater\changeFieldPurgeTable
changeFieldPurgeTable( $table, $field, $newtype, $default)
Definition: PostgresUpdater.php:961
PostgresUpdater\addPgExtIndex
addPgExtIndex( $table, $index, $type)
Definition: PostgresUpdater.php:1050
PostgresUpdater\describeTable
describeTable( $table)
Definition: PostgresUpdater.php:705
PostgresUpdater\ruleDef
ruleDef( $table, $rule)
Definition: PostgresUpdater.php:803
PostgresUpdater\addPgIndex
addPgIndex( $table, $index, $type, $unique=false)
Definition: PostgresUpdater.php:1040
PostgresUpdater\checkRevUserFkey
checkRevUserFkey()
Definition: PostgresUpdater.php:1237
DatabaseUpdater\updateRowExists
updateRowExists( $key)
Helper function: check if the given key is present in the updatelog table.
Definition: DatabaseUpdater.php:510
PostgresUpdater
Class for handling updates to Postgres databases.
Definition: PostgresUpdater.php:32
PostgresUpdater\checkIndex
checkIndex( $index, $should_be, $good_def)
Definition: PostgresUpdater.php:1219
PostgresUpdater\changeFkeyDeferrable
changeFkeyDeferrable( $table, $field, $clause)
Definition: PostgresUpdater.php:1119
PostgresUpdater\renameSequence
renameSequence( $old, $new)
Definition: PostgresUpdater.php:846
PostgresUpdater\dropDefault
dropDefault( $table, $field)
Drop a default value from a field.
Definition: PostgresUpdater.php:1005
PostgresUpdater\setSequenceOwner
setSequenceOwner( $table, $pkey, $seq)
Definition: PostgresUpdater.php:858
$command
$command
Definition: mcc.php:125
PostgresUpdater\addInterwikiType
addInterwikiType()
Definition: PostgresUpdater.php:1259
PostgresUpdater\dropSequence
dropSequence( $table, $ns)
Definition: PostgresUpdater.php:839
PostgresUpdater\addSequence
addSequence( $table, $pkey, $ns)
Definition: PostgresUpdater.php:827
PostgresUpdater\tsearchFixes
tsearchFixes()
Definition: PostgresUpdater.php:1263
PostgresUpdater\addPgField
addPgField( $table, $field, $type)
Definition: PostgresUpdater.php:924
PostgresUpdater\dropPgField
dropPgField( $table, $field)
Definition: PostgresUpdater.php:912
PostgresUpdater\checkOiDeleted
checkOiDeleted()
Definition: PostgresUpdater.php:1167
PostgresUpdater\getOldGlobalUpdates
getOldGlobalUpdates()
Before 1.17, we used to handle updates via stuff like $wgExtNewTables/Fields/Indexes.
Definition: PostgresUpdater.php:666
PostgresUpdater\dropPgIndex
dropPgIndex( $table, $index)
Definition: PostgresUpdater.php:1212
$type
$type
Definition: testCompression.php:50