46 [
'checkIndex',
'ipb_address_unique', [
47 [
'ipb_address',
'text_ops',
'btree', 0 ],
48 [
'ipb_user',
'int4_ops',
'btree', 0 ],
49 [
'ipb_auto',
'int2_ops',
'btree', 0 ],
51 'CREATE UNIQUE INDEX ipb_address_unique ' .
52 'ON ipblocks (ipb_address,ipb_user,ipb_auto)' ],
55 [
'addInterwikiType' ],
60 [
'addPgField',
'recentchanges',
'rc_source',
"TEXT NOT NULL DEFAULT ''" ],
61 [
'addPgField',
'page',
'page_links_updated',
"TIMESTAMPTZ NULL" ],
62 [
'addPgField',
'mwuser',
'user_password_expires',
'TIMESTAMPTZ NULL' ],
63 [
'changeFieldPurgeTable',
'l10n_cache',
'lc_value',
'bytea',
64 "replace(lc_value,'\','\\\\')::bytea" ],
66 [
'rebuildTextSearch' ],
69 [
'addPgField',
'page_props',
'pp_sortkey',
'float NULL' ],
70 [
'addPgIndex',
'page_props',
'pp_propname_sortkey_page',
71 '( pp_propname, pp_sortkey, pp_page ) WHERE ( pp_sortkey IS NOT NULL )' ],
72 [
'addPgField',
'page',
'page_lang',
'TEXT default NULL' ],
73 [
'addPgField',
'pagelinks',
'pl_from_namespace',
'INTEGER NOT NULL DEFAULT 0' ],
74 [
'addPgField',
'templatelinks',
'tl_from_namespace',
'INTEGER NOT NULL DEFAULT 0' ],
75 [
'addPgField',
'imagelinks',
'il_from_namespace',
'INTEGER NOT NULL DEFAULT 0' ],
80 [
'dropTable',
'msg_resource_links' ],
81 [
'dropTable',
'msg_resource' ],
83 'addPgField',
'watchlist',
'wl_id',
84 "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('watchlist_wl_id_seq')"
86 [
'addTable',
'bot_passwords',
'patch-bot_passwords.sql' ],
89 [
'addPgIndex',
'recentchanges',
'rc_name_type_patrolled_timestamp',
90 '( rc_namespace, rc_type, rc_patrolled, rc_timestamp )' ],
91 [
'addPgField',
'change_tag',
'ct_id',
92 "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('change_tag_ct_id_seq')" ],
95 [
'addPgField',
'externallinks',
'el_index_60',
"BYTEA NOT NULL DEFAULT ''" ],
96 [
'addPgIndex',
'externallinks',
'el_index_60',
'( el_index_60, el_id )' ],
97 [
'addPgIndex',
'externallinks',
'el_from_index_60',
'( el_from, el_index_60, el_id )' ],
98 [
'addPgField',
'user_groups',
'ug_expiry',
"TIMESTAMPTZ NULL" ],
99 [
'addPgIndex',
'user_groups',
'user_groups_expiry',
'( ug_expiry )' ],
102 [
'addPgEnumValue',
'media_type',
'3D' ],
103 [
'setDefault',
'revision',
'rev_comment',
'' ],
104 [
'changeNullableField',
'revision',
'rev_comment',
'NOT NULL',
true ],
105 [
'setDefault',
'archive',
'ar_comment',
'' ],
106 [
'changeNullableField',
'archive',
'ar_comment',
'NOT NULL',
true ],
107 [
'addPgField',
'archive',
'ar_comment_id',
'INTEGER NOT NULL DEFAULT 0' ],
108 [
'setDefault',
'ipblocks',
'ipb_reason',
'' ],
109 [
'addPgField',
'ipblocks',
'ipb_reason_id',
'INTEGER NOT NULL DEFAULT 0' ],
110 [
'setDefault',
'image',
'img_description',
'' ],
111 [
'setDefault',
'oldimage',
'oi_description',
'' ],
112 [
'changeNullableField',
'oldimage',
'oi_description',
'NOT NULL',
true ],
113 [
'addPgField',
'oldimage',
'oi_description_id',
'INTEGER NOT NULL DEFAULT 0' ],
114 [
'setDefault',
'filearchive',
'fa_deleted_reason',
'' ],
115 [
'changeNullableField',
'filearchive',
'fa_deleted_reason',
'NOT NULL',
true ],
116 [
'addPgField',
'filearchive',
'fa_deleted_reason_id',
'INTEGER NOT NULL DEFAULT 0' ],
117 [
'setDefault',
'filearchive',
'fa_description',
'' ],
118 [
'addPgField',
'filearchive',
'fa_description_id',
'INTEGER NOT NULL DEFAULT 0' ],
119 [
'setDefault',
'recentchanges',
'rc_comment',
'' ],
120 [
'changeNullableField',
'recentchanges',
'rc_comment',
'NOT NULL',
true ],
121 [
'addPgField',
'recentchanges',
'rc_comment_id',
'INTEGER NOT NULL DEFAULT 0' ],
122 [
'setDefault',
'logging',
'log_comment',
'' ],
123 [
'changeNullableField',
'logging',
'log_comment',
'NOT NULL',
true ],
124 [
'addPgField',
'logging',
'log_comment_id',
'INTEGER NOT NULL DEFAULT 0' ],
125 [
'setDefault',
'protected_titles',
'pt_reason',
'' ],
126 [
'changeNullableField',
'protected_titles',
'pt_reason',
'NOT NULL',
true ],
127 [
'addPgField',
'protected_titles',
'pt_reason_id',
'INTEGER NOT NULL DEFAULT 0' ],
128 [
'addTable',
'comment',
'patch-comment-table.sql' ],
129 [
'addTable',
'revision_comment_temp',
'patch-revision_comment_temp-table.sql' ],
136 [
'addPgField',
'image',
'img_description_id',
'INTEGER NOT NULL DEFAULT 0' ],
138 [
'migrateComments' ],
139 [
'addIndex',
'site_stats',
'site_stats_pkey',
'patch-site_stats-pk.sql' ],
140 [
'addTable',
'ip_changes',
'patch-ip_changes.sql' ],
143 [
'addTable',
'slots',
'patch-slots-table.sql' ],
144 [
'dropPgIndex',
'slots',
'slot_role_inherited' ],
145 [
'dropPgField',
'slots',
'slot_inherited' ],
146 [
'addPgField',
'slots',
'slot_origin',
'INTEGER NOT NULL' ],
150 'slot_revision_origin_role',
151 '( slot_revision_id, slot_origin, slot_role_id )',
153 [
'addTable',
'content',
'patch-content-table.sql' ],
154 [
'addTable',
'content_models',
'patch-content_models-table.sql' ],
155 [
'addTable',
'slot_roles',
'patch-slot_roles-table.sql' ],
156 [
'migrateArchiveText' ],
157 [
'addTable',
'actor',
'patch-actor-table.sql' ],
158 [
'addTable',
'revision_actor_temp',
'patch-revision_actor_temp-table.sql' ],
159 [
'setDefault',
'revision',
'rev_user', 0 ],
160 [
'setDefault',
'revision',
'rev_user_text',
'' ],
161 [
'setDefault',
'archive',
'ar_user', 0 ],
162 [
'changeNullableField',
'archive',
'ar_user',
'NOT NULL',
true ],
163 [
'setDefault',
'archive',
'ar_user_text',
'' ],
164 [
'addPgField',
'archive',
'ar_actor',
'INTEGER NOT NULL DEFAULT 0' ],
165 [
'setDefault',
'ipblocks',
'ipb_by', 0 ],
166 [
'addPgField',
'ipblocks',
'ipb_by_actor',
'INTEGER NOT NULL DEFAULT 0' ],
167 [
'setDefault',
'image',
'img_user', 0 ],
168 [
'changeNullableField',
'image',
'img_user',
'NOT NULL',
true ],
169 [
'setDefault',
'image',
'img_user_text',
'' ],
170 [
'addPgField',
'image',
'img_actor',
'INTEGER NOT NULL DEFAULT 0' ],
171 [
'setDefault',
'oldimage',
'oi_user', 0 ],
172 [
'changeNullableField',
'oldimage',
'oi_user',
'NOT NULL',
true ],
173 [
'setDefault',
'oldimage',
'oi_user_text',
'' ],
174 [
'addPgField',
'oldimage',
'oi_actor',
'INTEGER NOT NULL DEFAULT 0' ],
175 [
'setDefault',
'filearchive',
'fa_user', 0 ],
176 [
'changeNullableField',
'filearchive',
'fa_user',
'NOT NULL',
true ],
177 [
'setDefault',
'filearchive',
'fa_user_text',
'' ],
178 [
'addPgField',
'filearchive',
'fa_actor',
'INTEGER NOT NULL DEFAULT 0' ],
179 [
'setDefault',
'recentchanges',
'rc_user', 0 ],
180 [
'changeNullableField',
'recentchanges',
'rc_user',
'NOT NULL',
true ],
181 [
'setDefault',
'recentchanges',
'rc_user_text',
'' ],
182 [
'addPgField',
'recentchanges',
'rc_actor',
'INTEGER NOT NULL DEFAULT 0' ],
183 [
'setDefault',
'logging',
'log_user', 0 ],
184 [
'changeNullableField',
'logging',
'log_user',
'NOT NULL',
true ],
185 [
'addPgField',
'logging',
'log_actor',
'INTEGER NOT NULL DEFAULT 0' ],
186 [
'addPgIndex',
'logging',
'logging_actor_time_backwards',
'( log_timestamp, log_actor )' ],
187 [
'addPgIndex',
'logging',
'logging_actor_type_time',
'( log_actor, log_type, log_timestamp )' ],
188 [
'addPgIndex',
'logging',
'logging_actor_time',
'( log_actor, log_timestamp )' ],
190 [
'modifyTable',
'site_stats',
'patch-site_stats-modify.sql' ],
191 [
'populateArchiveRevId' ],
192 [
'dropPgIndex',
'recentchanges',
'rc_namespace_title' ],
196 'rc_namespace_title_timestamp',
'( rc_namespace, rc_title, rc_timestamp )'
198 [
'setSequenceOwner',
'mwuser',
'user_id',
'user_user_id_seq' ],
199 [
'setSequenceOwner',
'actor',
'actor_id',
'actor_actor_id_seq' ],
200 [
'setSequenceOwner',
'page',
'page_id',
'page_page_id_seq' ],
201 [
'setSequenceOwner',
'revision',
'rev_id',
'revision_rev_id_seq' ],
202 [
'setSequenceOwner',
'ip_changes',
'ipc_rev_id',
'ip_changes_ipc_rev_id_seq' ],
203 [
'setSequenceOwner',
'text',
'old_id',
'text_old_id_seq' ],
204 [
'setSequenceOwner',
'comment',
'comment_id',
'comment_comment_id_seq' ],
205 [
'setSequenceOwner',
'page_restrictions',
'pr_id',
'page_restrictions_pr_id_seq' ],
206 [
'setSequenceOwner',
'archive',
'ar_id',
'archive_ar_id_seq' ],
207 [
'setSequenceOwner',
'content',
'content_id',
'content_content_id_seq' ],
208 [
'setSequenceOwner',
'slot_roles',
'role_id',
'slot_roles_role_id_seq' ],
209 [
'setSequenceOwner',
'content_models',
'model_id',
'content_models_model_id_seq' ],
210 [
'setSequenceOwner',
'externallinks',
'el_id',
'externallinks_el_id_seq' ],
211 [
'setSequenceOwner',
'ipblocks',
'ipb_id',
'ipblocks_ipb_id_seq' ],
212 [
'setSequenceOwner',
'filearchive',
'fa_id',
'filearchive_fa_id_seq' ],
213 [
'setSequenceOwner',
'uploadstash',
'us_id',
'uploadstash_us_id_seq' ],
214 [
'setSequenceOwner',
'recentchanges',
'rc_id',
'recentchanges_rc_id_seq' ],
215 [
'setSequenceOwner',
'watchlist',
'wl_id',
'watchlist_wl_id_seq' ],
216 [
'setSequenceOwner',
'logging',
'log_id',
'logging_log_id_seq' ],
217 [
'setSequenceOwner',
'job',
'job_id',
'job_job_id_seq' ],
218 [
'setSequenceOwner',
'category',
'cat_id',
'category_cat_id_seq' ],
219 [
'setSequenceOwner',
'change_tag',
'ct_id',
'change_tag_ct_id_seq' ],
220 [
'setSequenceOwner',
'sites',
'site_id',
'sites_site_id_seq' ],
223 [
'addTable',
'change_tag_def',
'patch-change_tag_def.sql' ],
224 [
'populateExternallinksIndex60' ],
225 [
'dropDefault',
'externallinks',
'el_index_60' ],
226 [
'runMaintenance', DeduplicateArchiveRevId::class,
'maintenance/deduplicateArchiveRevId.php' ],
227 [
'addPgField',
'change_tag',
'ct_tag_id',
'INTEGER NULL' ],
231 'change_tag_tag_id_id',
232 '( ct_tag_id, ct_rc_id, ct_rev_id, ct_log_id )'
234 [
'addPgIndex',
'archive',
'ar_revid_uniq',
'(ar_rev_id)',
'unique' ],
235 [
'dropPgIndex',
'archive',
'ar_revid' ],
236 [
'populateContentTables' ],
237 [
'addPgIndex',
'logging',
'log_type_action',
'( log_type, log_action, log_timestamp )' ],
238 [
'dropPgIndex',
'page_props',
'page_props_propname' ],
239 [
'addIndex',
'interwiki',
'interwiki_pkey',
'patch-interwiki-pk.sql' ],
240 [
'addIndex',
'protected_titles',
'protected_titles_pkey',
'patch-protected_titles-pk.sql' ],
241 [
'addIndex',
'site_identifiers',
'site_identifiers_pkey',
'patch-site_identifiers-pk.sql' ],
242 [
'addPgIndex',
'recentchanges',
'rc_this_oldid',
'(rc_this_oldid)' ],
243 [
'dropTable',
'transcache' ],
244 [
'runMaintenance', PopulateChangeTagDef::class,
'maintenance/populateChangeTagDef.php' ],
245 [
'addIndex',
'change_tag',
'change_tag_rc_tag_id',
246 'patch-change_tag-change_tag_rc_tag_id.sql' ],
247 [
'addPgField',
'ipblocks',
'ipb_sitewide',
'SMALLINT NOT NULL DEFAULT 1' ],
248 [
'addTable',
'ipblocks_restrictions',
'patch-ipblocks_restrictions-table.sql' ],
249 [
'migrateImageCommentTemp' ],
250 [
'dropPgField',
'category',
'cat_hidden' ],
251 [
'dropPgField',
'site_stats',
'ss_admins' ],
252 [
'dropPgField',
'recentchanges',
'rc_cur_time' ],
255 [
'dropField',
'change_tag',
'ct_tag',
'patch-drop-ct_tag.sql' ],
256 [
'dropTable',
'valid_tag' ],
257 [
'dropTable',
'tag_summary' ],
258 [
'dropPgField',
'archive',
'ar_comment' ],
259 [
'dropDefault',
'archive',
'ar_comment_id' ],
260 [
'dropPgField',
'ipblocks',
'ipb_reason' ],
261 [
'dropDefault',
'ipblocks',
'ipb_reason_id' ],
262 [
'dropPgField',
'image',
'img_description' ],
263 [
'dropDefault',
'image',
'img_description_id' ],
264 [
'dropPgField',
'oldimage',
'oi_description' ],
265 [
'dropDefault',
'oldimage',
'oi_description_id' ],
266 [
'dropPgField',
'filearchive',
'fa_deleted_reason' ],
267 [
'dropDefault',
'filearchive',
'fa_deleted_reason_id' ],
268 [
'dropPgField',
'filearchive',
'fa_description' ],
269 [
'dropDefault',
'filearchive',
'fa_description_id' ],
270 [
'dropPgField',
'recentchanges',
'rc_comment' ],
271 [
'dropDefault',
'recentchanges',
'rc_comment_id' ],
272 [
'dropPgField',
'logging',
'log_comment' ],
273 [
'dropDefault',
'logging',
'log_comment_id' ],
274 [
'dropPgField',
'protected_titles',
'pt_reason' ],
275 [
'dropDefault',
'protected_titles',
'pt_reason_id' ],
278 [
'dropPgIndex',
'archive',
'archive_user_text' ],
279 [
'dropPgField',
'archive',
'ar_user' ],
280 [
'dropPgField',
'archive',
'ar_user_text' ],
281 [
'dropDefault',
'archive',
'ar_actor' ],
282 [
'dropPgField',
'ipblocks',
'ipb_by' ],
283 [
'dropPgField',
'ipblocks',
'ipb_by_text' ],
284 [
'dropDefault',
'ipblocks',
'ipb_by_actor' ],
285 [
'dropPgField',
'image',
'img_user' ],
286 [
'dropPgField',
'image',
'img_user_text' ],
287 [
'dropDefault',
'image',
'img_actor' ],
288 [
'dropPgField',
'oldimage',
'oi_user' ],
289 [
'dropPgField',
'oldimage',
'oi_user_text' ],
290 [
'dropDefault',
'oldimage',
'oi_actor' ],
291 [
'dropPgField',
'filearchive',
'fa_user' ],
292 [
'dropPgField',
'filearchive',
'fa_user_text' ],
293 [
'dropDefault',
'filearchive',
'fa_actor' ],
294 [
'dropPgField',
'recentchanges',
'rc_user' ],
295 [
'dropPgField',
'recentchanges',
'rc_user_text' ],
296 [
'dropDefault',
'recentchanges',
'rc_actor' ],
297 [
'dropPgIndex',
'logging',
'logging_user_time' ],
298 [
'dropPgIndex',
'logging',
'logging_user_type_time' ],
299 [
'dropPgIndex',
'logging',
'logging_user_text_type_time' ],
300 [
'dropPgIndex',
'logging',
'logging_user_text_time' ],
301 [
'dropPgField',
'logging',
'log_user' ],
302 [
'dropPgField',
'logging',
'log_user_text' ],
303 [
'dropDefault',
'logging',
'log_actor' ],
306 [
'addIndex',
'redirect',
'redirect_pkey',
'patch-redirect-pk.sql' ],
307 [
'addTable',
'watchlist_expiry',
'patch-watchlist_expiry.sql' ],
308 [
'setSequenceOwner',
'watchlist_expiry',
'we_item',
'watchlist_expiry_we_item_seq' ],
309 [
'setDefault',
'user_newtalk',
'user_ip',
'' ],
310 [
'changeNullableField',
'user_newtalk',
'user_ip',
'NOT NULL',
true ],
311 [
'setDefault',
'user_newtalk',
'user_id', 0 ],
312 [
'renameIndex',
'revision_actor_temp',
'rev_actor_timestamp',
'revactor_actor_timestamp' ],
313 [
'renameIndex',
'revision_actor_temp',
314 'rev_page_actor_timestamp',
'revactor_page_actor_timestamp' ],
315 [
'dropPgIndex',
'revision',
'rev_user_idx' ],
316 [
'dropPgIndex',
'revision',
'rev_user_text_idx' ],
317 [
'dropPgIndex',
'revision',
'rev_text_id_idx' ],
318 [
'dropPgField',
'revision',
'rev_user' ],
319 [
'dropPgField',
'revision',
'rev_user_text' ],
320 [
'dropPgField',
'revision',
'rev_comment' ],
321 [
'dropPgField',
'revision',
'rev_text_id' ],
322 [
'dropPgField',
'revision',
'rev_content_model' ],
323 [
'dropPgField',
'revision',
'rev_content_format' ],
324 [
'addPgField',
'revision',
'rev_comment_id',
'INTEGER NOT NULL DEFAULT 0' ],
325 [
'addPgField',
'revision',
'rev_actor',
'INTEGER NOT NULL DEFAULT 0' ],
326 [
'addPgIndex',
'revision',
'rev_actor_timestamp',
'(rev_actor,rev_timestamp,rev_id)' ],
327 [
'addPgIndex',
'revision',
'rev_page_actor_timestamp',
'(rev_page,rev_actor,rev_timestamp)' ],
328 [
'dropPgField',
'archive',
'ar_text_id' ],
329 [
'dropPgField',
'archive',
'ar_content_model' ],
330 [
'dropPgField',
'archive',
'ar_content_format' ],
331 [
'changeField',
'updatelog',
'ul_key',
'varchar(255)',
'' ],
332 [
'changeField',
'updatelog',
'ul_value',
'TEXT',
'' ],
333 [
'changeField',
'site_identifiers',
'si_type',
'TEXT',
'' ],
334 [
'changeField',
'site_identifiers',
'si_key',
'TEXT',
'' ],
335 [
'changeField',
'actor',
'actor_id',
'BIGINT',
'' ],
336 [
'changeField',
'actor',
'actor_name',
'TEXT',
'' ],
337 [
'changeField',
'user_former_groups',
'ufg_group',
'TEXT',
'' ],
338 [
'dropFkey',
'user_former_groups',
'ufg_user' ],
341 [
'setDefault',
'bot_passwords',
'bp_token',
'' ],
342 [
'changeField',
'comment',
'comment_id',
'BIGINT',
'' ],
343 [
'changeField',
'slots',
'slot_revision_id',
'BIGINT',
'' ],
344 [
'changeField',
'slots',
'slot_content_id',
'BIGINT',
'' ],
345 [
'changeField',
'slots',
'slot_origin',
'BIGINT',
'' ],
346 [
'changeField',
'site_stats',
'ss_total_edits',
'BIGINT',
'' ],
347 [
'changeField',
'site_stats',
'ss_good_articles',
'BIGINT',
'' ],
348 [
'changeField',
'site_stats',
'ss_total_pages',
'BIGINT',
'' ],
349 [
'changeField',
'site_stats',
'ss_users',
'BIGINT',
'' ],
350 [
'changeField',
'site_stats',
'ss_active_users',
'BIGINT',
'' ],
351 [
'changeField',
'site_stats',
'ss_images',
'BIGINT',
'' ],
352 [
'dropFkey',
'user_properties',
'up_user' ],
353 [
'addIndex',
'user_properties',
'user_properties_pkey',
'patch-user_properties-pk.sql' ],
354 [
'changeField',
'log_search',
'ls_value',
'VARCHAR(255)',
'' ],
355 [
'changeField',
'content',
'content_id',
'BIGINT',
'' ],
356 [
'changeField',
'l10n_cache',
'lc_value',
'TEXT',
'' ],
357 [
'changeField',
'l10n_cache',
'lc_key',
'VARCHAR(255)',
'' ],
358 [
'addIndex',
'l10n_cache',
'l10n_cache_pkey',
'patch-l10n_cache-pk.sql' ],
359 [
'addIndex',
'module_deps',
'module_deps_pkey',
'patch-module_deps-pk.sql' ],
360 [
'changeField',
'redirect',
'rd_namespace',
'INT',
'rd_namespace::INT DEFAULT 0' ],
361 [
'setDefault',
'redirect',
'rd_title',
'' ],
362 [
'setDefault',
'redirect',
'rd_from', 0 ],
363 [
'dropFkey',
'redirect',
'rd_from' ],
364 [
'changeField',
'redirect',
'rd_interwiki',
'VARCHAR(32)',
'' ],
365 [
'dropFkey',
'pagelinks',
'pl_from' ],
366 [
'changeField',
'pagelinks',
'pl_namespace',
'INT',
'pl_namespace::INT DEFAULT 0' ],
367 [
'setDefault',
'pagelinks',
'pl_title',
'' ],
368 [
'addPgIndex',
'pagelinks',
'pl_namespace',
'(pl_namespace,pl_title,pl_from)' ],
369 [
'addPgIndex',
'pagelinks',
'pl_backlinks_namespace',
370 '(pl_from_namespace,pl_namespace,pl_title,pl_from)' ],
371 [
'dropPgIndex',
'pagelinks',
'pagelink_unique' ],
372 [
'dropPgIndex',
'pagelinks',
'pagelinks_title' ],
373 [
'dropFkey',
'templatelinks',
'tl_from' ],
374 [
'changeField',
'templatelinks',
'tl_namespace',
'INT',
'tl_namespace::INT DEFAULT 0' ],
375 [
'setDefault',
'templatelinks',
'tl_title',
'' ],
376 [
'addPgIndex',
'templatelinks',
'tl_namespace',
'(tl_namespace,tl_title,tl_from)' ],
377 [
'addPgIndex',
'templatelinks',
'tl_backlinks_namespace',
378 '(tl_from_namespace,tl_namespace,tl_title,tl_from)' ],
379 [
'dropPgIndex',
'templatelinks',
'templatelinks_unique' ],
380 [
'dropPgIndex',
'templatelinks',
'templatelinks_from' ],
381 [
'dropFkey',
'imagelinks',
'il_from' ],
382 [
'setDefault',
'imagelinks',
'il_to',
'' ],
383 [
'addPgIndex',
'imagelinks',
'il_to',
'(il_to, il_from)' ],
384 [
'addPgIndex',
'imagelinks',
'il_backlinks_namespace',
385 '(il_from_namespace, il_to, il_from)' ],
386 [
'dropPgIndex',
'imagelinks',
'il_from' ],
387 [
'dropFkey',
'langlinks',
'll_from' ],
388 [
'addIndex',
'langlinks',
'langlinks_pkey',
'patch-langlinks-pk.sql' ],
389 [
'renameIndex',
'langlinks',
'langlinks_lang_title',
'll_lang' ],
390 [
'setDefault',
'langlinks',
'll_lang',
'' ],
391 [
'setDefault',
'langlinks',
'll_from', 0 ],
392 [
'setDefault',
'langlinks',
'll_title',
'' ],
393 [
'changeNullableField',
'langlinks',
'll_lang',
'NOT NULL',
true ],
394 [
'changeNullableField',
'langlinks',
'll_title',
'NOT NULL',
true ],
395 [
'addIndex',
'iwlinks',
'iwlinks_pkey',
'patch-iwlinks-pk.sql' ],
396 [
'renameIndex',
'category',
'category_title',
'cat_title' ],
397 [
'renameIndex',
'category',
'category_pages',
'cat_pages' ],
398 [
'dropSequence',
'watchlist_expiry',
'watchlist_expiry_we_item_seq' ],
399 [
'changeField',
'change_tag_def',
'ctd_count',
'BIGINT',
'ctd_count::BIGINT DEFAULT 0' ],
400 [
'dropDefault',
'change_tag_def',
'ctd_user_defined' ],
401 [
'dropFkey',
'ipblocks_restrictions',
'ir_ipb_id' ],
402 [
'setDefault',
'querycache',
'qc_value', 0 ],
403 [
'changeField',
'querycache',
'qc_namespace',
'INT',
'qc_namespace::INT DEFAULT 0' ],
404 [
'setDefault',
'querycache',
'qc_title',
'' ],
405 [
'renameIndex',
'querycache',
'querycache_type_value',
'qc_type' ],
406 [
'renameIndex',
'querycachetwo',
'querycachetwo_type_value',
'qcc_type' ],
407 [
'renameIndex',
'querycachetwo',
'querycachetwo_title',
'qcc_title' ],
408 [
'renameIndex',
'querycachetwo',
'querycachetwo_titletwo',
'qcc_titletwo' ],
409 [
'dropFkey',
'page_restrictions',
'pr_page' ],
410 [
'addPgIndex',
'page_restrictions',
'pr_pagetype',
'(pr_page, pr_type)',
true ],
411 [
'addPgIndex',
'page_restrictions',
'pr_typelevel',
'(pr_type, pr_level)' ],
412 [
'addPgIndex',
'page_restrictions',
'pr_level',
'(pr_level)' ],
413 [
'addPgIndex',
'page_restrictions',
'pr_cascade',
'(pr_cascade)' ],
414 [
'changePrimaryKey',
'page_restrictions', [
'pr_id' ],
'page_restrictions_pk' ] ,
415 [
'dropPgIndex',
'page_restrictions',
'page_restrictions_pr_id_key' ],
416 [
'changeNullableField',
'page_restrictions',
'pr_page',
'NOT NULL',
true ],
417 [
'dropFkey',
'user_groups',
'ug_user' ],
418 [
'setDefault',
'user_groups',
'ug_user', 0 ],
419 [
'setDefault',
'user_groups',
'ug_group',
'' ],
420 [
'renameIndex',
'user_groups',
'user_groups_group',
'ug_group' ],
421 [
'renameIndex',
'user_groups',
'user_groups_expiry',
'ug_expiry' ],
422 [
'setDefault',
'querycache_info',
'qci_type',
'' ],
423 [
'setDefault',
'querycache_info',
'qci_timestamp',
'1970-01-01 00:00:00+00' ],
424 [
'changeNullableField',
'querycache_info',
'qci_type',
'NOT NULL',
true ],
425 [
'changeNullableField',
'querycache_info',
'qci_timestamp',
'NOT NULL',
true ],
426 [
'addIndex',
'querycache_info',
'querycache_info_pkey',
'patch-querycache_info-pk.sql' ],
427 [
'setDefault',
'watchlist',
'wl_title',
'' ],
428 [
'changeField',
'watchlist',
'wl_namespace',
'INT', 0 ],
429 [
'dropFkey',
'watchlist',
'wl_user' ],
430 [
'dropPgIndex',
'watchlist',
'wl_user_namespace_title' ],
431 [
'addPgIndex',
'watchlist',
'namespace_title',
'(wl_namespace, wl_title)' ],
432 [
'checkIndex',
'wl_user', [
433 [
'wl_user',
'text_ops',
'btree', 1 ],
434 [
'wl_namespace',
'int4_ops',
'btree', 1 ],
435 [
'wl_title',
'text_ops',
'btree', 1 ],
437 'CREATE UNIQUE INDEX "wl_user" ON "watchlist" (wl_user, wl_namespace, wl_title) ' ],
438 [
'changeField',
'sites',
'site_domain',
'VARCHAR(255)',
'' ],
439 [
'renameIndex',
'sites',
'site_global_key',
'sites_global_key' ],
440 [
'renameIndex',
'sites',
'site_type',
'sites_type' ],
441 [
'renameIndex',
'sites',
'site_group',
'sites_group' ],
442 [
'renameIndex',
'sites',
'site_source',
'sites_source' ],
443 [
'renameIndex',
'sites',
'site_language',
'sites_language' ],
444 [
'renameIndex',
'sites',
'site_protocol',
'sites_protocol' ],
445 [
'renameIndex',
'sites',
'site_domain',
'sites_domain' ],
446 [
'renameIndex',
'sites',
'site_forward',
'sites_forward' ],
447 [
'dropFkey',
'user_newtalk',
'user_id ' ],
448 [
'renameIndex',
'user_newtalk',
'user_newtalk_id',
'un_user_id' ],
449 [
'renameIndex',
'user_newtalk',
'user_newtalk_ip',
'un_user_ip' ],
450 [
'changeField',
'interwiki',
'iw_prefix',
'VARCHAR(32)',
'' ],
451 [
'changeField',
'interwiki',
'iw_wikiid',
'VARCHAR(64)',
'' ],
452 [
'dropFkey',
'protected_titles',
'pt_user' ],
453 [
'changeNullableField',
'protected_titles',
'pt_user',
'NOT NULL',
true ],
454 [
'changeNullableField',
'protected_titles',
'pt_expiry',
'NOT NULL',
true ],
455 [
'changeField',
'protected_titles',
'pt_reason_id',
'BIGINT',
'' ],
456 [
'dropDefault',
'protected_titles',
'pt_create_perm' ],
457 [
'dropFkey',
'externallinks',
'el_from' ],
458 [
'setDefault',
'externallinks',
'el_from', 0 ],
459 [
'changeField',
'externallinks',
'el_index_60',
'TEXT',
'' ],
460 [
'renameIndex',
'externallinks',
'externallinks_from_to',
'el_from' ],
461 [
'renameIndex',
'externallinks',
'externallinks_index',
'el_index' ],
462 [
'addPgIndex',
'externallinks',
'el_to',
'(el_to, el_from)' ],
463 [
'dropSequence',
'ip_changes',
'ip_changes_ipc_rev_id_seq' ],
464 [
'changeField',
'ip_changes',
'ipc_hex',
'TEXT',
"ipc_hex::TEXT DEFAULT ''" ],
465 [
'setDefault',
'ip_changes',
'ipc_rev_id', 0 ],
466 [
'changeField',
'revision_comment_temp',
'revcomment_comment_id',
'BIGINT',
'' ],
467 [
'dropFkey',
'revision_actor_temp',
'revactor_page' ],
468 [
'changeField',
'revision_actor_temp',
'revactor_actor',
'BIGINT',
'' ],
469 [
'changeNullableField',
'revision_actor_temp',
'revactor_page',
'NOT NULL',
true ],
470 [
'renameIndex',
'watchlist',
'namespace_title',
'wl_namespace_title' ],
471 [
'dropFkey',
'page_props',
'pp_page' ],
473 [
'changePrimaryKey',
'page_props', [
'pp_page',
'pp_propname' ],
'page_props_pk' ],
474 [
'setDefault',
'job',
'job_cmd',
'' ],
475 [
'changeField',
'job',
'job_namespace',
'INTEGER',
'' ],
476 [
'dropPgIndex',
'job',
'job_cmd_namespace_title' ],
477 [
'addPgIndex',
'job',
'job_cmd',
'(job_cmd, job_namespace, job_title, job_params)' ],
478 [
'renameIndex',
'job',
'job_timestamp_idx',
'job_timestamp' ],
479 [
'changeField',
'slot_roles',
'role_id',
'INTEGER',
'' ],
480 [
'changeField',
'content_models',
'model_id',
'INTEGER',
'' ],
481 [
'renameIndex',
'page',
'page_len_idx',
'page_len' ],
482 [
'renameIndex',
'page',
'page_random_idx',
'page_random' ],
483 [
'renameIndex',
'page',
'page_unique_name',
'name_title' ],
484 [
'addPGIndex',
'page',
'page_redirect_namespace_len',
'(page_is_redirect, page_namespace, page_len)' ],
485 [
'dropFkey',
'categorylinks',
'cl_from' ],
486 [
'setDefault',
'categorylinks',
'cl_from', 0 ],
487 [
'setDefault',
'categorylinks',
'cl_to',
'' ],
488 [
'setDefault',
'categorylinks',
'cl_sortkey',
'' ],
489 [
'setDefault',
'categorylinks',
'cl_collation',
'' ],
490 [
'changeNullableField',
'categorylinks',
'cl_sortkey',
'NOT NULL',
true ],
491 [
'addIndex',
'categorylinks',
'categorylinks_pkey',
'patch-categorylinks-pk.sql' ],
492 [
'addPgIndex',
'categorylinks',
'cl_timestamp',
'(cl_to, cl_timestamp)' ],
493 [
'addPgIndex',
'categorylinks',
'cl_collation_ext',
'(cl_collation, cl_to, cl_type, cl_from)' ],
494 [
'checkIndex',
'cl_sortkey', [
495 [
'cl_to',
'text_ops',
'btree', 1 ],
496 [
'cl_type',
'text_ops',
'btree', 1 ],
497 [
'cl_sortkey',
'text_ops',
'btree', 1 ],
498 [
'cl_from',
'text_ops',
'btree', 1 ],
500 'CREATE INDEX cl_sortkey ON categorylinks (cl_to, cl_type, cl_sortkey, cl_from)' ],
501 [
'renameIndex',
'logging',
'logging_type_name',
'type_time' ],
502 [
'renameIndex',
'logging',
'logging_actor_time_backwards',
'actor_time' ],
503 [
'renameIndex',
'logging',
'logging_page_time',
'page_time' ],
504 [
'renameIndex',
'logging',
'logging_times',
'times' ],
505 [
'renameIndex',
'logging',
'logging_actor_type_time',
'log_actor_type_time' ],
506 [
'renameIndex',
'logging',
'logging_page_id_time',
'log_page_id_time' ],
507 [
'renameIndex',
'logging',
'logging_type_action',
'log_type_action' ],
508 [
'changeNullableField',
'logging',
'log_params',
'NOT NULL',
true ],
509 [
'setDefault',
'logging',
'log_action',
'' ],
510 [
'setDefault',
'logging',
'log_type',
'' ],
511 [
'setDefault',
'logging',
'log_title',
'' ],
512 [
'setDefault',
'logging',
'log_timestamp',
'1970-01-01 00:00:00+00' ],
513 [
'changeField',
'logging',
'log_actor',
'BIGINT',
'' ],
514 [
'changeField',
'logging',
'log_comment_id',
'BIGINT',
'' ],
515 [
'changeField',
'logging',
'log_namespace',
'INT',
'log_namespace::INT DEFAULT 0' ],
516 [
'dropPgIndex',
'logging',
'logging_actor_time' ],
517 [
'changeField',
'uploadstash',
'us_key',
'VARCHAR(255)',
'' ],
518 [
'changeField',
'uploadstash',
'us_orig_path',
'VARCHAR(255)',
'' ],
519 [
'changeField',
'uploadstash',
'us_path',
'VARCHAR(255)',
'' ],
520 [
'changeField',
'uploadstash',
'us_source_type',
'VARCHAR(50)',
'' ],
521 [
'changeField',
'uploadstash',
'us_props',
'TEXT',
'' ],
522 [
'changeField',
'uploadstash',
'us_status',
'VARCHAR(50)',
'' ],
523 [
'changeField',
'uploadstash',
'us_sha1',
'VARCHAR(31)',
'' ],
524 [
'changeField',
'uploadstash',
'us_mime',
'VARCHAR(255)',
'' ],
525 [
'changeNullableField',
'uploadstash',
'us_key',
'NOT NULL',
true ],
526 [
'changeNullableField',
'uploadstash',
'us_user',
'NOT NULL',
true ],
527 [
'changeNullableField',
'uploadstash',
'us_orig_path',
'NOT NULL',
true ],
528 [
'changeNullableField',
'uploadstash',
'us_path',
'NOT NULL',
true ],
529 [
'changeNullableField',
'uploadstash',
'us_timestamp',
'NOT NULL',
true ],
530 [
'changeNullableField',
'uploadstash',
'us_status',
'NOT NULL',
true ],
531 [
'changeNullableField',
'uploadstash',
'us_size',
'NOT NULL',
true ],
532 [
'changeNullableField',
'uploadstash',
'us_sha1',
'NOT NULL',
true ],
533 [
'renameIndex',
'uploadstash',
'us_user_idx',
'us_user' ],
534 [
'renameIndex',
'uploadstash',
'us_key_idx',
'us_key' ],
535 [
'renameIndex',
'uploadstash',
'us_timestamp_idx',
'us_timestamp' ],
536 [
'renameIndex',
'user_properties',
'user_properties_property',
'up_property' ],
537 [
'renameIndex',
'sites',
'sites_global_key',
'site_global_key' ],
538 [
'renameIndex',
'sites',
'sites_type',
'site_type' ],
539 [
'renameIndex',
'sites',
'sites_group, ',
'site_group' ],
540 [
'renameIndex',
'sites',
'sites_source',
'site_source' ],
541 [
'renameIndex',
'sites',
'sites_language',
'site_language' ],
542 [
'renameIndex',
'sites',
'sites_protocol',
'site_protocol' ],
543 [
'renameIndex',
'sites',
'sites_domain',
'site_domain' ],
544 [
'renameIndex',
'sites',
'sites_forward',
'site_forward' ],
545 [
'renameIndex',
'logging',
'type_name',
'log_type_time' ],
546 [
'renameIndex',
'logging',
'actor_time',
'log_actor_time' ],
547 [
'renameIndex',
'logging',
'page_time',
'log_page_time' ],
548 [
'renameIndex',
'logging',
'times',
'log_times' ],
549 [
'setDefault',
'filearchive',
'fa_name',
'' ],
550 [
'setDefault',
'filearchive',
'fa_archive_name',
'' ],
551 [
'setDefault',
'filearchive',
'fa_storage_key',
'' ],
552 [
'dropFkey',
'filearchive',
'fa_deleted_user' ],
553 [
'changeField',
'filearchive',
'fa_deleted_reason_id',
'BIGINT',
'' ],
554 [
'changeField',
'filearchive',
'fa_metadata',
'TEXT',
'' ],
555 [
'changeField',
'filearchive',
'fa_bits',
'INTEGER',
'' ],
556 [
'changeField',
'filearchive',
'fa_description_id',
'BIGINT',
'' ],
557 [
'changeField',
'filearchive',
'fa_actor',
'BIGINT',
'' ],
558 [
'renameIndex',
'filearchive',
'fa_name_time',
'fa_name' ],
559 [
'renameIndex',
'filearchive',
'fa_dupe',
'fa_storage_group' ],
560 [
'renameIndex',
'filearchive',
'fa_notime',
'fa_deleted_timestamp' ],
561 [
'dropPgIndex',
'filearchive',
'fa_nouser' ],
562 [
'addPgIndex',
'filearchive',
'fa_actor_timestamp',
'(fa_actor, fa_timestamp)' ],
563 [
'addPgIndex',
'ipblocks',
'ipb_expiry',
'(ipb_expiry)' ],
564 [
'addPgIndex',
'ipblocks',
'ipb_timestamp',
'(ipb_timestamp)' ],
565 [
'renameTable',
'pagecontent',
'text' ],
566 [
'renameIndex',
'text',
'pagecontent_pkey',
'text_pkey' ],
567 [
'changeNullableField',
'text',
'old_text',
'NOT NULL',
true ],
568 [
'changeNullableField',
'text',
'old_flags',
'NOT NULL',
true ],
569 [
'setDefault',
'oldimage',
'oi_name',
'' ],
570 [
'setDefault',
'oldimage',
'oi_archive_name',
'' ],
571 [
'setDefault',
'oldimage',
'oi_size', 0 ],
572 [
'setDefault',
'oldimage',
'oi_width', 0 ],
573 [
'setDefault',
'oldimage',
'oi_height', 0 ],
574 [
'setDefault',
'oldimage',
'oi_bits', 0 ],
575 [
'setDefault',
'oldimage',
'oi_name',
'' ],
576 [
'changeField',
'oldimage',
'oi_bits',
'INTEGER',
'' ],
577 [
'changeField',
'oldimage',
'oi_description_id',
'BIGINT',
'' ],
578 [
'changeField',
'oldimage',
'oi_actor',
'BIGINT',
'' ],
579 [
'changeField',
'oldimage',
'oi_metadata',
'TEXT',
'' ],
580 [
'dropDefault',
'oldimage',
'oi_metadata' ],
581 [
'changeNullableField',
'oldimage',
'oi_minor_mime',
'NOT NULL',
true ],
582 [
'changeNullableField',
'oldimage',
'oi_minor_mime',
'NOT NULL',
true ],
583 [
'dropFkey',
'oldimage',
'oi_name' ],
584 [
'addPgIndex',
'oldimage',
'oi_actor_timestamp',
'(oi_actor, oi_timestamp)' ],
585 [
'dropPgIndex',
'recentchanges',
'rc_timestamp_bot' ],
586 [
'addPgIndex',
'recentchanges',
'rc_ns_actor',
'(rc_namespace, rc_actor)' ],
587 [
'addPgIndex',
'recentchanges',
'rc_actor',
'(rc_actor, rc_timestamp)' ],
588 [
'dropIndex',
'objectcache',
'keyname',
'patch-objectcache_keyname-pk.sql' ],
589 [
'changeField',
'objectcache',
'value',
'TEXT',
'' ],
590 [
'changeNullableField',
'objectcache',
'value',
'NULL',
true ],
591 [
'dropFkey',
'ipblocks',
'ipb_user' ],
592 [
'dropFkey',
'ipblocks',
'ipb_parent_block_id' ],
593 [
'setDefault',
'ipblocks',
'ipb_user', 0 ],
594 [
'changeNullableField',
'ipblocks',
'ipb_user',
'NOT NULL',
true ],
595 [
'changeNullableField',
'ipblocks',
'ipb_range_start',
'NOT NULL',
true ],
596 [
'changeNullableField',
'ipblocks',
'ipb_range_end',
'NOT NULL',
true ],
597 [
'changeField',
'ipblocks',
'ipb_by_actor',
'BIGINT',
'' ],
598 [
'changeField',
'ipblocks',
'ipb_reason_id',
'BIGINT',
'' ],
599 [
'renameIndex',
'archive',
'archive_name_title_timestamp',
'ar_name_title_timestamp' ],
600 [
'dropPgIndex',
'archive',
'archive_actor' ],
601 [
'addPgIndex',
'archive',
'ar_actor_timestamp',
'(ar_actor,ar_timestamp)' ],
602 [
'setDefault',
'image',
'img_name',
'' ],
603 [
'setDefault',
'image',
'img_size', 0 ],
604 [
'setDefault',
'image',
'img_width', 0 ],
605 [
'setDefault',
'image',
'img_height', 0 ],
606 [
'setDefault',
'image',
'img_bits', 0 ],
607 [
'changeField',
'image',
'img_bits',
'INTEGER',
'' ],
608 [
'changeField',
'image',
'img_description_id',
'BIGINT',
'' ],
609 [
'changeField',
'image',
'img_actor',
'BIGINT',
'' ],
610 [
'changeField',
'image',
'img_metadata',
'TEXT',
'' ],
611 [
'dropDefault',
'image',
'img_metadata' ],
612 [
'changeNullableField',
'image',
'img_major_mime',
'NOT NULL',
true ],
613 [
'changeNullableField',
'image',
'img_minor_mime',
'NOT NULL',
true ],
614 [
'changeNullableField',
'image',
'img_timestamp',
'NOT NULL',
true ],
615 [
'addPgIndex',
'image',
'img_actor_timestamp',
'(oi_actor, oi_timestamp)' ],
616 [
'renameIndex',
'image',
'img_size_idx',
'img_size' ],
617 [
'renameIndex',
'image',
'img_timestamp_idx',
'img_timestamp' ],
618 [
'addPgIndex',
'image',
'img_actor_timestamp',
'(img_actor, img_timestamp)' ],
619 [
'addPgIndex',
'image',
'img_media_mime',
'(img_media_type, img_major_mime, img_minor_mime)' ],
620 [
'renameIndex',
'site_identifiers',
'site_ids_site',
'si_site' ],
621 [
'renameIndex',
'site_identifiers',
'site_ids_key',
'si_key' ],
622 [
'changeField',
'recentchanges',
'rc_actor',
'BIGINT',
'' ],
623 [
'changeField',
'recentchanges',
'rc_comment_id',
'BIGINT',
'' ],
624 [
'changeField',
'recentchanges',
'rc_ip',
'TEXT',
'' ],
625 [
'changeField',
'recentchanges',
'rc_namespace',
'INTEGER',
'' ],
626 [
'setDefault',
'recentchanges',
'rc_title',
'' ],
627 [
'setDefault',
'recentchanges',
'rc_source',
'' ],
628 [
'setDefault',
'recentchanges',
'rc_ip',
'' ],
629 [
'setDefault',
'recentchanges',
'rc_namespace', 0 ],
630 [
'setDefault',
'recentchanges',
'rc_cur_id', 0 ],
631 [
'setDefault',
'recentchanges',
'rc_this_oldid', 0 ],
632 [
'setDefault',
'recentchanges',
'rc_last_oldid', 0 ],
633 [
'changeNullableField',
'recentchanges',
'rc_cur_id',
'NOT NULL',
true ],
634 [
'changeNullableField',
'recentchanges',
'rc_ip',
'NOT NULL',
true ],
640 SELECT attname, attnum FROM pg_namespace, pg_class, pg_attribute
641 WHERE pg_class.relnamespace = pg_namespace.oid
642 AND attrelid=pg_class.oid AND attnum > 0
643 AND relname=%s AND nspname=%s
645 $res = $this->db->query(
647 $this->db->addQuotes( $table ),
648 $this->db->addQuotes( $this->db->getCoreSchema() )
657 foreach (
$res as $r ) {
671 SELECT indkey, indrelid FROM pg_namespace, pg_class, pg_index
673 AND pg_class.relnamespace = pg_namespace.oid
675 AND indexrelid=pg_class.oid
677 $res = $this->db->query(
680 $this->db->addQuotes( $this->db->getCoreSchema() ),
681 $this->db->addQuotes( $idx )
688 $r = $this->db->fetchRow(
$res );
694 $relid = intval( $r[1] );
695 $indkeys = explode(
' ', $indkey );
698 foreach ( $indkeys as $rid ) {
700 SELECT attname FROM pg_class, pg_attribute
701 WHERE attrelid=$relid
703 AND attrelid=pg_class.oid
705 $r2 = $this->db->query( sprintf( $query, $rid ), __METHOD__ );
709 $row2 = $this->db->fetchRow( $r2 );
713 $colnames[] = $row2[0];
721 SELECT confdeltype FROM pg_constraint, pg_namespace
722 WHERE connamespace=pg_namespace.oid
726 $r = $this->db->query(
729 $this->db->addQuotes( $this->db->getCoreSchema() ),
730 $this->db->addQuotes( $fkey )
734 $row = $this->db->fetchRow( $r );
744 SELECT definition FROM pg_rules
745 WHERE schemaname = %s
749 $r = $this->db->query(
752 $this->db->addQuotes( $this->db->getCoreSchema() ),
753 $this->db->addQuotes( $table ),
754 $this->db->addQuotes( $rule )
758 $row = $this->db->fetchRow( $r );
768 if ( !$this->db->sequenceExists( $ns ) ) {
769 $this->
output(
"Creating sequence $ns\n" );
770 if ( $pkey !==
false ) {
771 $this->db->query(
"CREATE SEQUENCE $ns OWNED BY $table.$pkey", __METHOD__ );
772 $this->
setDefault( $table, $pkey,
'"nextval"(\'"' . $ns .
'"\'::"regclass")' );
774 $this->db->query(
"CREATE SEQUENCE $ns", __METHOD__ );
780 if ( $this->db->sequenceExists( $ns ) ) {
781 $this->
output(
"Dropping sequence $ns\n" );
782 $this->db->query(
"DROP SEQUENCE $ns CASCADE", __METHOD__ );
787 if ( $this->db->sequenceExists( $new ) ) {
788 $this->
output(
"...sequence $new already exists.\n" );
792 if ( $this->db->sequenceExists( $old ) ) {
793 $this->
output(
"Renaming sequence $old to $new\n" );
794 $this->db->query(
"ALTER SEQUENCE $old RENAME TO $new", __METHOD__ );
799 if ( $this->db->sequenceExists( $seq ) ) {
800 $this->
output(
"Setting sequence $seq owner to $table.$pkey\n" );
801 $this->db->query(
"ALTER SEQUENCE $seq OWNED BY $table.$pkey", __METHOD__ );
806 if ( $this->db->tableExists( $old, __METHOD__ ) ) {
807 $this->
output(
"Renaming table $old to $new\n" );
808 $old = $this->db->realTableName( $old,
"quoted" );
809 $new = $this->db->realTableName( $new,
"quoted" );
810 $this->db->query(
"ALTER TABLE $old RENAME TO $new", __METHOD__ );
811 if ( $patch !==
false ) {
818 $table, $old, $new, $skipBothIndexExistWarning =
false, $a =
false, $b =
false
821 if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
822 $this->
output(
"...skipping: '$table' table doesn't exist yet.\n" );
828 if ( $this->db->indexExists( $table, $new, __METHOD__ ) ) {
829 $this->
output(
"...index $new already set on $table table.\n" );
830 if ( !$skipBothIndexExistWarning
831 && $this->db->indexExists( $table, $old, __METHOD__ )
833 $this->
output(
"...WARNING: $old still exists, despite it has been " .
834 "renamed into $new (which also exists).\n" .
835 " $old should be manually removed if not needed anymore.\n" );
842 if ( !$this->db->indexExists( $table, $old, __METHOD__ ) ) {
843 $this->
output(
"...skipping: index $old doesn't exist.\n" );
848 $this->db->query(
"ALTER INDEX $old RENAME TO $new", __METHOD__ );
853 $fi = $this->db->fieldInfo( $table, $field );
854 if ( $fi ===
null ) {
855 $this->
output(
"...$table table does not contain $field field.\n" );
859 $this->
output(
"Dropping column '$table.$field'\n" );
860 $this->db->query(
"ALTER TABLE $table DROP COLUMN $field", __METHOD__ );
865 $fi = $this->db->fieldInfo( $table, $field );
866 if ( $fi !==
null ) {
867 $this->
output(
"...column '$table.$field' already exists\n" );
871 $this->
output(
"Adding column '$table.$field'\n" );
872 $this->db->query(
"ALTER TABLE $table ADD $field $type", __METHOD__ );
876 protected function changeField( $table, $field, $newtype, $default ) {
877 $fi = $this->db->fieldInfo( $table, $field );
878 if ( $fi ===
null ) {
879 $this->
output(
"...ERROR: expected column $table.$field to exist\n" );
883 if ( $fi->type() === $newtype ) {
884 $this->
output(
"...column '$table.$field' is already of type '$newtype'\n" );
886 $this->
output(
"Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
887 $sql =
"ALTER TABLE $table ALTER $field TYPE $newtype";
888 if ( strlen( $default ) ) {
890 if ( preg_match(
'/DEFAULT (.+)/', $default,
$res ) ) {
891 $sqldef =
"ALTER TABLE $table ALTER $field SET DEFAULT $res[1]";
892 $this->db->query( $sqldef, __METHOD__ );
893 $default = preg_replace(
'/\s*DEFAULT .+/',
'', $default );
895 $sql .=
" USING $default";
897 $this->db->query( $sql, __METHOD__ );
902 # # For a cache table, empty it if the field needs to be changed, because the old contents
903 # # may be corrupted. If the column is already the desired type, refrain from purging.
904 $fi = $this->db->fieldInfo( $table, $field );
905 if ( $fi ===
null ) {
906 $this->
output(
"...ERROR: expected column $table.$field to exist\n" );
910 if ( $fi->type() === $newtype ) {
911 $this->
output(
"...column '$table.$field' is already of type '$newtype'\n" );
913 $this->
output(
"Purging data from cache table '$table'\n" );
914 $this->db->query(
"DELETE from $table", __METHOD__ );
915 $this->
output(
"Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
916 $sql =
"ALTER TABLE $table ALTER $field TYPE $newtype";
917 if ( strlen( $default ) ) {
919 if ( preg_match(
'/DEFAULT (.+)/', $default,
$res ) ) {
920 $sqldef =
"ALTER TABLE $table ALTER $field SET DEFAULT $res[1]";
921 $this->db->query( $sqldef, __METHOD__ );
922 $default = preg_replace(
'/\s*DEFAULT .+/',
'', $default );
924 $sql .=
" USING $default";
926 $this->db->query( $sql, __METHOD__ );
931 $info = $this->db->fieldInfo( $table, $field );
932 if ( $info && $info->defaultValue() !== $default ) {
933 $this->
output(
"Changing '$table.$field' default value\n" );
934 $this->db->query(
"ALTER TABLE $table ALTER $field SET DEFAULT "
935 . $this->db->addQuotes( $default ), __METHOD__ );
946 $info = $this->db->fieldInfo( $table, $field );
947 if ( $info->defaultValue() !==
false ) {
948 $this->
output(
"Removing '$table.$field' default value\n" );
949 $this->db->query(
"ALTER TABLE $table ALTER $field DROP DEFAULT", __METHOD__ );
954 $fi = $this->db->fieldInfo( $table, $field );
955 if ( $fi ===
null ) {
958 if ( $fi->isNullable() ) {
959 # # It's NULL - does it need to be NOT NULL?
960 if ( $null ===
'NOT NULL' ) {
961 $this->
output(
"Changing '$table.$field' to not allow NULLs\n" );
963 $this->db->query(
"UPDATE $table SET $field = DEFAULT WHERE $field IS NULL", __METHOD__ );
965 $this->db->query(
"ALTER TABLE $table ALTER $field SET NOT NULL", __METHOD__ );
967 $this->
output(
"...column '$table.$field' is already set as NULL\n" );
970 # # It's NOT NULL - does it need to be NULL?
971 if ( $null ===
'NULL' ) {
972 $this->
output(
"Changing '$table.$field' to allow NULLs\n" );
973 $this->db->query(
"ALTER TABLE $table ALTER $field DROP NOT NULL", __METHOD__ );
975 $this->
output(
"...column '$table.$field' is already set as NOT NULL\n" );
981 if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
982 $this->
output(
"...index '$index' on table '$table' already exists\n" );
984 $this->
output(
"Creating index '$index' on table '$table' $type\n" );
985 $unique = $unique ?
'UNIQUE' :
'';
986 $this->db->query(
"CREATE $unique INDEX $index ON $table $type", __METHOD__ );
991 if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
992 $this->
output(
"...index '$index' on table '$table' already exists\n" );
993 } elseif ( preg_match(
'/^\(/',
$type ) ) {
994 $this->
output(
"Creating index '$index' on table '$table'\n" );
995 $this->db->query(
"CREATE INDEX $index ON $table $type", __METHOD__ );
997 $this->
applyPatch(
$type,
true,
"Creating index '$index' on table '$table'" );
1008 $row = $this->db->selectRow(
1010 't' =>
'pg_catalog.pg_type',
1011 'n' =>
'pg_catalog.pg_namespace',
1012 'e' =>
'pg_catalog.pg_enum',
1014 [
't.typname',
't.typtype',
'e.enumlabel' ],
1016 't.typname' =>
$type,
1017 'n.nspname' => $this->db->getCoreSchema(),
1022 'n' => [
'JOIN',
't.typnamespace = n.oid' ],
1023 'e' => [
'LEFT JOIN', [
'e.enumtypid = t.oid',
'e.enumlabel' => $value ] ],
1028 $this->
output(
"...Type $type does not exist, skipping modify enum.\n" );
1029 } elseif ( $row->typtype !==
'e' ) {
1030 $this->
output(
"...Type $type does not seem to be an enum, skipping modify enum.\n" );
1031 } elseif ( $row->enumlabel === $value ) {
1032 $this->
output(
"...Enum type $type already contains value '$value'.\n" );
1034 $this->
output(
"...Adding value '$value' to enum type $type.\n" );
1035 $etype = $this->db->addIdentifierQuotes(
$type );
1036 $evalue = $this->db->addQuotes( $value );
1037 $this->db->query(
"ALTER TYPE $etype ADD VALUE $evalue", __METHOD__ );
1042 $fi = $this->db->fieldInfo( $table, $field );
1043 if ( $fi ===
null ) {
1044 $this->
output(
"WARNING! Column '$table.$field' does not exist but it should! " .
1045 "Please report this.\n" );
1048 $conname = $fi->conname();
1049 if ( $fi->conname() ) {
1050 $this->
output(
"Dropping foreign key constraint on '$table.$field'\n" );
1051 $conclause =
"CONSTRAINT \"$conname\"";
1052 $command =
"ALTER TABLE $table DROP CONSTRAINT $conname";
1053 $this->db->query(
$command, __METHOD__ );
1055 $this->
output(
"...foreign key constraint on '$table.$field' already does not exist\n" );
1060 $fi = $this->db->fieldInfo( $table, $field );
1061 if ( $fi ===
null ) {
1062 $this->
output(
"WARNING! Column '$table.$field' does not exist but it should! " .
1063 "Please report this.\n" );
1067 if ( $fi->is_deferred() && $fi->is_deferrable() ) {
1070 $this->
output(
"Altering column '$table.$field' to be DEFERRABLE INITIALLY DEFERRED\n" );
1071 $conname = $fi->conname();
1072 if ( $fi->conname() ) {
1073 $conclause =
"CONSTRAINT \"$conname\"";
1074 $command =
"ALTER TABLE $table DROP CONSTRAINT $conname";
1075 $this->db->query(
$command, __METHOD__ );
1077 $this->
output(
"Column '$table.$field' does not have a foreign key " .
1078 "constraint, will be added\n" );
1082 "ALTER TABLE $table ADD $conclause " .
1083 "FOREIGN KEY ($field) REFERENCES $clause DEFERRABLE INITIALLY DEFERRED";
1084 $this->db->query(
$command, __METHOD__ );
1088 if ( $this->db->tableExists(
"archive2", __METHOD__ ) ) {
1089 if ( $this->db->ruleExists(
'archive',
'archive_insert' ) ) {
1090 $this->
output(
"Dropping rule 'archive_insert'\n" );
1091 $this->db->query(
'DROP RULE archive_insert ON archive', __METHOD__ );
1093 if ( $this->db->ruleExists(
'archive',
'archive_delete' ) ) {
1094 $this->
output(
"Dropping rule 'archive_delete'\n" );
1095 $this->db->query(
'DROP RULE archive_delete ON archive', __METHOD__ );
1098 'patch-remove-archive2.sql',
1100 "Converting 'archive2' back to normal archive table"
1103 $this->
output(
"...obsolete table 'archive2' does not exist\n" );
1108 if ( $this->db->fieldInfo(
'oldimage',
'oi_deleted' )->type() !==
'smallint' ) {
1109 $this->
output(
"Changing 'oldimage.oi_deleted' to type 'smallint'\n" );
1110 $this->db->query(
"ALTER TABLE oldimage ALTER oi_deleted DROP DEFAULT", __METHOD__ );
1112 "ALTER TABLE oldimage ALTER oi_deleted TYPE SMALLINT USING (oi_deleted::smallint)", __METHOD__ );
1113 $this->db->query(
"ALTER TABLE oldimage ALTER oi_deleted SET DEFAULT 0", __METHOD__ );
1115 $this->
output(
"...column 'oldimage.oi_deleted' is already of type 'smallint'\n" );
1120 if ( $this->db->hasConstraint(
"oldimage_oi_name_fkey_cascaded" ) ) {
1121 $this->
output(
"...table 'oldimage' has correct cascading delete/update " .
1122 "foreign key to image\n" );
1124 if ( $this->db->hasConstraint(
"oldimage_oi_name_fkey" ) ) {
1126 "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey", __METHOD__ );
1128 if ( $this->db->hasConstraint(
"oldimage_oi_name_fkey_cascade" ) ) {
1130 "ALTER TABLE oldimage DROP CONSTRAINT oldimage_oi_name_fkey_cascade", __METHOD__ );
1132 $this->
output(
"Making foreign key on table 'oldimage' (to image) a cascade delete/update\n" );
1134 "ALTER TABLE oldimage ADD CONSTRAINT oldimage_oi_name_fkey_cascaded " .
1135 "FOREIGN KEY (oi_name) REFERENCES image(img_name) " .
1136 "ON DELETE CASCADE ON UPDATE CASCADE", __METHOD__ );
1141 if ( !$this->db->triggerExists(
'page',
'page_deleted' ) ) {
1143 'patch-page_deleted.sql',
1145 "Adding function and trigger 'page_deleted' to table 'page'"
1148 $this->
output(
"...table 'page' has 'page_deleted' trigger\n" );
1153 if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
1154 $this->
output(
"Dropping obsolete index '$index'\n" );
1155 $this->db->query(
"DROP INDEX \"" . $index .
"\"", __METHOD__ );
1160 $pu = $this->db->indexAttributes( $index );
1161 if ( !empty( $pu ) && $pu != $should_be ) {
1162 $this->
output(
"Dropping obsolete version of index '$index'\n" );
1163 $this->db->query(
"DROP INDEX \"" . $index .
"\"", __METHOD__ );
1166 $this->
output(
"...no need to drop index '$index'\n" );
1169 if ( empty( $pu ) ) {
1170 $this->
output(
"Creating index '$index'\n" );
1171 $this->db->query( $good_def, __METHOD__ );
1173 $this->
output(
"...index '$index' exists\n" );
1179 $result = $this->db->query(
1180 "SELECT a.attname as column " .
1181 "FROM pg_index i " .
1182 "JOIN pg_attribute a ON a.attrelid = i.indrelid " .
1183 "AND a.attnum = ANY(i.indkey) " .
1184 "WHERE i.indrelid = '\"$table\"'::regclass " .
1185 "AND i.indisprimary"
1187 $currentColumns = [];
1188 foreach ( $result as $row ) {
1189 $currentColumns[] = $row->column;
1192 if ( $currentColumns == $shouldBe ) {
1193 $this->
output(
"...no need to change primary key of '$table'\n" );
1197 if ( !$constraintName ) {
1198 $constraintName = $table .
'_pkey';
1201 if ( $this->db->constraintExists( $table, $constraintName ) ) {
1203 "ALTER TABLE $table" .
1204 " DROP CONSTRAINT {$constraintName};",
1210 "ALTER TABLE $table" .
1211 " ADD PRIMARY KEY (" . implode(
',', $shouldBe ) .
');',
1217 if ( !$this->db->fieldExists(
'revision',
'rev_user', __METHOD__ ) ) {
1219 } elseif ( $this->
fkeyDeltype(
'revision_rev_user_fkey' ) ==
'r' ) {
1220 $this->
output(
"...constraint 'revision_rev_user_fkey' is ON DELETE RESTRICT\n" );
1223 'patch-revision_rev_user_fkey.sql',
1225 "Changing constraint 'revision_rev_user_fkey' to ON DELETE RESTRICT"
1231 $this->
applyPatch(
'patch-add_interwiki.sql',
false,
"Refreshing add_interwiki()" );
1235 # Tweak the page_title tsearch2 trigger to filter out slashes
1236 # This is create or replace, so harmless to call if not needed
1237 $this->
applyPatch(
'patch-ts2pagetitle.sql',
false,
"Refreshing ts2_page_title()" );
1239 $this->
applyPatch(
'patch-tsearch2funcs.sql',
false,
"Rewriting tsearch2 triggers" );
1244 $this->
output(
"...T68650 already fixed or not applicable.\n" );
1247 $this->
applyPatch(
'patch-textsearch_bug66650.sql',
false,
1248 'Rebuilding text search for T68650' );