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