45 [
'addPgField',
'revision',
'rev_actor',
'INTEGER NOT NULL DEFAULT 0' ],
46 [
'addPgIndex',
'revision',
'rev_actor_timestamp',
'(rev_actor,rev_timestamp,rev_id)' ],
47 [
'addPgIndex',
'revision',
'rev_page_actor_timestamp',
'(rev_page,rev_actor,rev_timestamp)' ],
51 [
'renameTable',
'pagecontent',
'text' ],
53 [
'renameTable',
'mwuser',
'user' ],
56 [
'addPgField',
'image',
'img_description_id',
'INTEGER NOT NULL DEFAULT 0' ],
57 [
'migrateComments' ],
59 [
'addTable',
'slots',
'patch-slots-table.sql' ],
60 [
'dropPgIndex',
'slots',
'slot_role_inherited' ],
61 [
'dropPgField',
'slots',
'slot_inherited' ],
62 [
'addPgField',
'slots',
'slot_origin',
'INTEGER NOT NULL' ],
66 'slot_revision_origin_role',
67 '( slot_revision_id, slot_origin, slot_role_id )',
69 [
'addTable',
'content',
'patch-content-table.sql' ],
70 [
'addTable',
'content_models',
'patch-content_models-table.sql' ],
71 [
'addTable',
'slot_roles',
'patch-slot_roles-table.sql' ],
72 [
'migrateArchiveText' ],
73 [
'addTable',
'actor',
'patch-actor-table.sql' ],
74 [
'setDefault',
'revision',
'rev_user', 0 ],
75 [
'setDefault',
'revision',
'rev_user_text',
'' ],
76 [
'setDefault',
'archive',
'ar_user', 0 ],
77 [
'changeNullableField',
'archive',
'ar_user',
'NOT NULL',
true ],
78 [
'setDefault',
'archive',
'ar_user_text',
'' ],
79 [
'addPgField',
'archive',
'ar_actor',
'INTEGER NOT NULL DEFAULT 0' ],
80 [
'setDefault',
'ipblocks',
'ipb_by', 0 ],
81 [
'addPgField',
'ipblocks',
'ipb_by_actor',
'INTEGER NOT NULL DEFAULT 0' ],
82 [
'setDefault',
'image',
'img_user', 0 ],
83 [
'changeNullableField',
'image',
'img_user',
'NOT NULL',
true ],
84 [
'setDefault',
'image',
'img_user_text',
'' ],
85 [
'addPgField',
'image',
'img_actor',
'INTEGER NOT NULL DEFAULT 0' ],
86 [
'setDefault',
'oldimage',
'oi_user', 0 ],
87 [
'changeNullableField',
'oldimage',
'oi_user',
'NOT NULL',
true ],
88 [
'setDefault',
'oldimage',
'oi_user_text',
'' ],
89 [
'addPgField',
'oldimage',
'oi_actor',
'INTEGER NOT NULL DEFAULT 0' ],
90 [
'setDefault',
'filearchive',
'fa_user', 0 ],
91 [
'changeNullableField',
'filearchive',
'fa_user',
'NOT NULL',
true ],
92 [
'setDefault',
'filearchive',
'fa_user_text',
'' ],
93 [
'addPgField',
'filearchive',
'fa_actor',
'INTEGER NOT NULL DEFAULT 0' ],
94 [
'setDefault',
'recentchanges',
'rc_user', 0 ],
95 [
'changeNullableField',
'recentchanges',
'rc_user',
'NOT NULL',
true ],
96 [
'setDefault',
'recentchanges',
'rc_user_text',
'' ],
97 [
'addPgField',
'recentchanges',
'rc_actor',
'INTEGER NOT NULL DEFAULT 0' ],
98 [
'setDefault',
'logging',
'log_user', 0 ],
99 [
'changeNullableField',
'logging',
'log_user',
'NOT NULL',
true ],
100 [
'addPgField',
'logging',
'log_actor',
'INTEGER NOT NULL DEFAULT 0' ],
101 [
'addPgIndex',
'logging',
'logging_actor_time_backwards',
'( log_timestamp, log_actor )' ],
102 [
'addPgIndex',
'logging',
'logging_actor_type_time',
'( log_actor, log_type, log_timestamp )' ],
103 [
'addPgIndex',
'logging',
'logging_actor_time',
'( log_actor, log_timestamp )' ],
105 [
'modifyTable',
'site_stats',
'patch-site_stats-modify.sql' ],
106 [
'populateArchiveRevId' ],
107 [
'dropPgIndex',
'recentchanges',
'rc_namespace_title' ],
111 'rc_namespace_title_timestamp',
'( rc_namespace, rc_title, rc_timestamp )'
113 [
'setSequenceOwner',
'user',
'user_id',
'user_user_id_seq' ],
114 [
'setSequenceOwner',
'actor',
'actor_id',
'actor_actor_id_seq' ],
115 [
'setSequenceOwner',
'page',
'page_id',
'page_page_id_seq' ],
116 [
'setSequenceOwner',
'revision',
'rev_id',
'revision_rev_id_seq' ],
117 [
'setSequenceOwner',
'ip_changes',
'ipc_rev_id',
'ip_changes_ipc_rev_id_seq' ],
118 [
'setSequenceOwner',
'text',
'old_id',
'text_old_id_seq' ],
119 [
'setSequenceOwner',
'comment',
'comment_id',
'comment_comment_id_seq' ],
120 [
'setSequenceOwner',
'page_restrictions',
'pr_id',
'page_restrictions_pr_id_seq' ],
121 [
'setSequenceOwner',
'archive',
'ar_id',
'archive_ar_id_seq' ],
122 [
'setSequenceOwner',
'content',
'content_id',
'content_content_id_seq' ],
123 [
'setSequenceOwner',
'slot_roles',
'role_id',
'slot_roles_role_id_seq' ],
124 [
'setSequenceOwner',
'content_models',
'model_id',
'content_models_model_id_seq' ],
125 [
'setSequenceOwner',
'externallinks',
'el_id',
'externallinks_el_id_seq' ],
126 [
'setSequenceOwner',
'ipblocks',
'ipb_id',
'ipblocks_ipb_id_seq' ],
127 [
'setSequenceOwner',
'filearchive',
'fa_id',
'filearchive_fa_id_seq' ],
128 [
'setSequenceOwner',
'uploadstash',
'us_id',
'uploadstash_us_id_seq' ],
129 [
'setSequenceOwner',
'recentchanges',
'rc_id',
'recentchanges_rc_id_seq' ],
130 [
'setSequenceOwner',
'watchlist',
'wl_id',
'watchlist_wl_id_seq' ],
131 [
'setSequenceOwner',
'logging',
'log_id',
'logging_log_id_seq' ],
132 [
'setSequenceOwner',
'job',
'job_id',
'job_job_id_seq' ],
133 [
'setSequenceOwner',
'category',
'cat_id',
'category_cat_id_seq' ],
134 [
'setSequenceOwner',
'change_tag',
'ct_id',
'change_tag_ct_id_seq' ],
135 [
'setSequenceOwner',
'sites',
'site_id',
'sites_site_id_seq' ],
138 [
'addTable',
'change_tag_def',
'patch-change_tag_def.sql' ],
139 [
'populateExternallinksIndex60' ],
140 [
'dropDefault',
'externallinks',
'el_index_60' ],
141 [
'runMaintenance', DeduplicateArchiveRevId::class ],
142 [
'addPgField',
'change_tag',
'ct_tag_id',
'INTEGER NULL' ],
146 'change_tag_tag_id_id',
147 '( ct_tag_id, ct_rc_id, ct_rev_id, ct_log_id )'
149 [
'addPgIndex',
'archive',
'ar_revid_uniq',
'(ar_rev_id)',
'unique' ],
150 [
'dropPgIndex',
'archive',
'ar_revid' ],
151 [
'populateContentTables' ],
152 [
'addPgIndex',
'logging',
'log_type_action',
'( log_type, log_action, log_timestamp )' ],
153 [
'dropPgIndex',
'page_props',
'page_props_propname' ],
154 [
'addIndex',
'interwiki',
'interwiki_pkey',
'patch-interwiki-pk.sql' ],
155 [
'addIndex',
'protected_titles',
'protected_titles_pkey',
'patch-protected_titles-pk.sql' ],
156 [
'addIndex',
'site_identifiers',
'site_identifiers_pkey',
'patch-site_identifiers-pk.sql' ],
157 [
'addPgIndex',
'recentchanges',
'rc_this_oldid',
'(rc_this_oldid)' ],
158 [
'dropTable',
'transcache' ],
159 [
'runMaintenance', PopulateChangeTagDef::class ],
160 [
'dropIndex',
'change_tag',
'change_tag_rc_tag',
'patch-change_tag-change_tag_rc_tag_id.sql' ],
161 [
'addPgField',
'ipblocks',
'ipb_sitewide',
'SMALLINT NOT NULL DEFAULT 1' ],
162 [
'addTable',
'ipblocks_restrictions',
'patch-ipblocks_restrictions-table.sql' ],
163 [
'migrateImageCommentTemp' ],
164 [
'dropPgField',
'category',
'cat_hidden' ],
165 [
'dropPgField',
'site_stats',
'ss_admins' ],
166 [
'dropPgField',
'recentchanges',
'rc_cur_time' ],
169 [
'dropField',
'change_tag',
'ct_tag',
'patch-drop-ct_tag.sql' ],
170 [
'dropTable',
'valid_tag' ],
171 [
'dropTable',
'tag_summary' ],
172 [
'dropPgField',
'archive',
'ar_comment' ],
173 [
'dropDefault',
'archive',
'ar_comment_id' ],
174 [
'dropPgField',
'ipblocks',
'ipb_reason' ],
175 [
'dropDefault',
'ipblocks',
'ipb_reason_id' ],
176 [
'dropPgField',
'image',
'img_description' ],
177 [
'dropDefault',
'image',
'img_description_id' ],
178 [
'dropPgField',
'oldimage',
'oi_description' ],
179 [
'dropDefault',
'oldimage',
'oi_description_id' ],
180 [
'dropPgField',
'filearchive',
'fa_deleted_reason' ],
181 [
'dropDefault',
'filearchive',
'fa_deleted_reason_id' ],
182 [
'dropPgField',
'filearchive',
'fa_description' ],
183 [
'dropDefault',
'filearchive',
'fa_description_id' ],
184 [
'dropPgField',
'recentchanges',
'rc_comment' ],
185 [
'dropDefault',
'recentchanges',
'rc_comment_id' ],
186 [
'dropPgField',
'logging',
'log_comment' ],
187 [
'dropDefault',
'logging',
'log_comment_id' ],
188 [
'dropPgField',
'protected_titles',
'pt_reason' ],
189 [
'dropDefault',
'protected_titles',
'pt_reason_id' ],
192 [
'dropPgIndex',
'archive',
'archive_user_text' ],
193 [
'dropPgField',
'archive',
'ar_user' ],
194 [
'dropPgField',
'archive',
'ar_user_text' ],
195 [
'dropDefault',
'archive',
'ar_actor' ],
196 [
'dropPgField',
'ipblocks',
'ipb_by' ],
197 [
'dropPgField',
'ipblocks',
'ipb_by_text' ],
198 [
'dropDefault',
'ipblocks',
'ipb_by_actor' ],
199 [
'dropPgField',
'image',
'img_user' ],
200 [
'dropPgField',
'image',
'img_user_text' ],
201 [
'dropDefault',
'image',
'img_actor' ],
202 [
'dropPgField',
'oldimage',
'oi_user' ],
203 [
'dropPgField',
'oldimage',
'oi_user_text' ],
204 [
'dropDefault',
'oldimage',
'oi_actor' ],
205 [
'dropPgField',
'filearchive',
'fa_user' ],
206 [
'dropPgField',
'filearchive',
'fa_user_text' ],
207 [
'dropDefault',
'filearchive',
'fa_actor' ],
208 [
'dropPgField',
'recentchanges',
'rc_user' ],
209 [
'dropPgField',
'recentchanges',
'rc_user_text' ],
210 [
'dropDefault',
'recentchanges',
'rc_actor' ],
211 [
'dropPgIndex',
'logging',
'logging_user_time' ],
212 [
'dropPgIndex',
'logging',
'logging_user_type_time' ],
213 [
'dropPgIndex',
'logging',
'logging_user_text_type_time' ],
214 [
'dropPgIndex',
'logging',
'logging_user_text_time' ],
215 [
'dropPgField',
'logging',
'log_user' ],
216 [
'dropPgField',
'logging',
'log_user_text' ],
217 [
'dropDefault',
'logging',
'log_actor' ],
220 [
'addIndex',
'redirect',
'redirect_pkey',
'patch-redirect-pk.sql' ],
221 [
'addTable',
'watchlist_expiry',
'patch-watchlist_expiry.sql' ],
222 [
'setSequenceOwner',
'watchlist_expiry',
'we_item',
'watchlist_expiry_we_item_seq' ],
223 [
'setDefault',
'user_newtalk',
'user_ip',
'' ],
224 [
'changeNullableField',
'user_newtalk',
'user_ip',
'NOT NULL',
true ],
225 [
'setDefault',
'user_newtalk',
'user_id', 0 ],
226 [
'dropPgIndex',
'revision',
'rev_user_idx' ],
227 [
'dropPgIndex',
'revision',
'rev_user_text_idx' ],
228 [
'dropPgIndex',
'revision',
'rev_text_id_idx' ],
229 [
'dropPgField',
'revision',
'rev_user' ],
230 [
'dropPgField',
'revision',
'rev_user_text' ],
231 [
'dropPgField',
'revision',
'rev_comment' ],
232 [
'dropPgField',
'revision',
'rev_text_id' ],
233 [
'dropPgField',
'revision',
'rev_content_model' ],
234 [
'dropPgField',
'revision',
'rev_content_format' ],
235 [
'addPgField',
'revision',
'rev_comment_id',
'INTEGER NOT NULL DEFAULT 0' ],
236 [
'dropPgField',
'archive',
'ar_text_id' ],
237 [
'dropPgField',
'archive',
'ar_content_model' ],
238 [
'dropPgField',
'archive',
'ar_content_format' ],
239 [
'changeField',
'updatelog',
'ul_key',
'varchar(255)',
'' ],
240 [
'changeField',
'updatelog',
'ul_value',
'TEXT',
'' ],
241 [
'changeField',
'site_identifiers',
'si_type',
'TEXT',
'' ],
242 [
'changeField',
'site_identifiers',
'si_key',
'TEXT',
'' ],
243 [
'changeField',
'actor',
'actor_id',
'BIGINT',
'' ],
244 [
'changeField',
'actor',
'actor_name',
'TEXT',
'' ],
245 [
'changeField',
'user_former_groups',
'ufg_group',
'TEXT',
'' ],
246 [
'dropFkey',
'user_former_groups',
'ufg_user' ],
247 [
'checkIndex',
'ipb_address_unique', [
248 [
'ipb_address',
'text_ops',
'btree', 0 ],
249 [
'ipb_user',
'int4_ops',
'btree', 0 ],
250 [
'ipb_auto',
'int2_ops',
'btree', 0 ],
252 'CREATE UNIQUE INDEX ipb_address_unique ' .
253 'ON ipblocks (ipb_address,ipb_user,ipb_auto)' ],
256 [
'setDefault',
'bot_passwords',
'bp_token',
'' ],
257 [
'changeField',
'comment',
'comment_id',
'BIGINT',
'' ],
258 [
'changeField',
'slots',
'slot_revision_id',
'BIGINT',
'' ],
259 [
'changeField',
'slots',
'slot_content_id',
'BIGINT',
'' ],
260 [
'changeField',
'slots',
'slot_origin',
'BIGINT',
'' ],
261 [
'changeField',
'site_stats',
'ss_total_edits',
'BIGINT',
'' ],
262 [
'changeField',
'site_stats',
'ss_good_articles',
'BIGINT',
'' ],
263 [
'changeField',
'site_stats',
'ss_total_pages',
'BIGINT',
'' ],
264 [
'changeField',
'site_stats',
'ss_users',
'BIGINT',
'' ],
265 [
'changeField',
'site_stats',
'ss_active_users',
'BIGINT',
'' ],
266 [
'changeField',
'site_stats',
'ss_images',
'BIGINT',
'' ],
267 [
'dropFkey',
'user_properties',
'up_user' ],
268 [
'addIndex',
'user_properties',
'user_properties_pkey',
'patch-user_properties-pk.sql' ],
269 [
'changeField',
'log_search',
'ls_value',
'VARCHAR(255)',
'' ],
270 [
'changeField',
'content',
'content_id',
'BIGINT',
'' ],
271 [
'changeField',
'l10n_cache',
'lc_value',
'TEXT',
'' ],
272 [
'changeField',
'l10n_cache',
'lc_key',
'VARCHAR(255)',
'' ],
273 [
'addIndex',
'l10n_cache',
'l10n_cache_pkey',
'patch-l10n_cache-pk.sql' ],
274 [
'addIndex',
'module_deps',
'module_deps_pkey',
'patch-module_deps-pk.sql' ],
275 [
'changeField',
'redirect',
'rd_namespace',
'INT',
'rd_namespace::INT DEFAULT 0' ],
276 [
'setDefault',
'redirect',
'rd_title',
'' ],
277 [
'setDefault',
'redirect',
'rd_from', 0 ],
278 [
'dropFkey',
'redirect',
'rd_from' ],
279 [
'changeField',
'redirect',
'rd_interwiki',
'VARCHAR(32)',
'' ],
280 [
'dropFkey',
'pagelinks',
'pl_from' ],
281 [
'changeField',
'pagelinks',
'pl_namespace',
'INT',
'pl_namespace::INT DEFAULT 0' ],
282 [
'setDefault',
'pagelinks',
'pl_title',
'' ],
283 [
'addPgIndex',
'pagelinks',
'pl_namespace',
'(pl_namespace,pl_title,pl_from)' ],
284 [
'addPgIndex',
'pagelinks',
'pl_backlinks_namespace',
285 '(pl_from_namespace,pl_namespace,pl_title,pl_from)' ],
286 [
'dropPgIndex',
'pagelinks',
'pagelink_unique' ],
287 [
'dropPgIndex',
'pagelinks',
'pagelinks_title' ],
288 [
'dropFkey',
'templatelinks',
'tl_from' ],
289 [
'dropPgIndex',
'templatelinks',
'templatelinks_unique' ],
290 [
'dropPgIndex',
'templatelinks',
'templatelinks_from' ],
291 [
'dropFkey',
'imagelinks',
'il_from' ],
292 [
'setDefault',
'imagelinks',
'il_to',
'' ],
293 [
'addPgIndex',
'imagelinks',
'il_to',
'(il_to, il_from)' ],
294 [
'addPgIndex',
'imagelinks',
'il_backlinks_namespace',
295 '(il_from_namespace, il_to, il_from)' ],
296 [
'dropPgIndex',
'imagelinks',
'il_from' ],
297 [
'dropFkey',
'langlinks',
'll_from' ],
298 [
'addIndex',
'langlinks',
'langlinks_pkey',
'patch-langlinks-pk.sql' ],
299 [
'renameIndex',
'langlinks',
'langlinks_lang_title',
'll_lang' ],
300 [
'setDefault',
'langlinks',
'll_lang',
'' ],
301 [
'setDefault',
'langlinks',
'll_from', 0 ],
302 [
'setDefault',
'langlinks',
'll_title',
'' ],
303 [
'changeNullableField',
'langlinks',
'll_lang',
'NOT NULL',
true ],
304 [
'changeNullableField',
'langlinks',
'll_title',
'NOT NULL',
true ],
305 [
'addIndex',
'iwlinks',
'iwlinks_pkey',
'patch-iwlinks-pk.sql' ],
306 [
'renameIndex',
'category',
'category_title',
'cat_title' ],
307 [
'renameIndex',
'category',
'category_pages',
'cat_pages' ],
308 [
'dropSequence',
'watchlist_expiry',
'watchlist_expiry_we_item_seq' ],
309 [
'changeField',
'change_tag_def',
'ctd_count',
'BIGINT',
'ctd_count::BIGINT DEFAULT 0' ],
310 [
'dropDefault',
'change_tag_def',
'ctd_user_defined' ],
311 [
'dropFkey',
'ipblocks_restrictions',
'ir_ipb_id' ],
312 [
'setDefault',
'querycache',
'qc_value', 0 ],
313 [
'changeField',
'querycache',
'qc_namespace',
'INT',
'qc_namespace::INT DEFAULT 0' ],
314 [
'setDefault',
'querycache',
'qc_title',
'' ],
315 [
'renameIndex',
'querycache',
'querycache_type_value',
'qc_type' ],
316 [
'renameIndex',
'querycachetwo',
'querycachetwo_type_value',
'qcc_type' ],
317 [
'renameIndex',
'querycachetwo',
'querycachetwo_title',
'qcc_title' ],
318 [
'renameIndex',
'querycachetwo',
'querycachetwo_titletwo',
'qcc_titletwo' ],
319 [
'dropFkey',
'page_restrictions',
'pr_page' ],
320 [
'addPgIndex',
'page_restrictions',
'pr_pagetype',
'(pr_page, pr_type)',
true ],
321 [
'addPgIndex',
'page_restrictions',
'pr_typelevel',
'(pr_type, pr_level)' ],
322 [
'addPgIndex',
'page_restrictions',
'pr_level',
'(pr_level)' ],
323 [
'addPgIndex',
'page_restrictions',
'pr_cascade',
'(pr_cascade)' ],
324 [
'changePrimaryKey',
'page_restrictions', [
'pr_id' ],
'page_restrictions_pk' ] ,
325 [
'changeNullableField',
'page_restrictions',
'pr_page',
'NOT NULL',
true ],
326 [
'dropFkey',
'user_groups',
'ug_user' ],
327 [
'setDefault',
'user_groups',
'ug_user', 0 ],
328 [
'setDefault',
'user_groups',
'ug_group',
'' ],
329 [
'renameIndex',
'user_groups',
'user_groups_group',
'ug_group' ],
330 [
'renameIndex',
'user_groups',
'user_groups_expiry',
'ug_expiry' ],
331 [
'setDefault',
'querycache_info',
'qci_type',
'' ],
332 [
'setDefault',
'querycache_info',
'qci_timestamp',
'1970-01-01 00:00:00+00' ],
333 [
'changeNullableField',
'querycache_info',
'qci_type',
'NOT NULL',
true ],
334 [
'changeNullableField',
'querycache_info',
'qci_timestamp',
'NOT NULL',
true ],
335 [
'addIndex',
'querycache_info',
'querycache_info_pkey',
'patch-querycache_info-pk.sql' ],
336 [
'setDefault',
'watchlist',
'wl_title',
'' ],
337 [
'changeField',
'watchlist',
'wl_namespace',
'INT',
'wl_namespace::INT DEFAULT 0' ],
338 [
'dropFkey',
'watchlist',
'wl_user' ],
339 [
'dropPgIndex',
'watchlist',
'wl_user_namespace_title' ],
340 [
'addPgIndex',
'watchlist',
'namespace_title',
'(wl_namespace, wl_title)' ],
341 [
'checkIndex',
'wl_user', [
342 [
'wl_user',
'text_ops',
'btree', 1 ],
343 [
'wl_namespace',
'int4_ops',
'btree', 1 ],
344 [
'wl_title',
'text_ops',
'btree', 1 ],
346 'CREATE UNIQUE INDEX "wl_user" ON "watchlist" (wl_user, wl_namespace, wl_title) ' ],
347 [
'changeField',
'sites',
'site_domain',
'VARCHAR(255)',
'' ],
348 [
'renameIndex',
'sites',
'site_global_key',
'sites_global_key' ],
349 [
'renameIndex',
'sites',
'site_type',
'sites_type' ],
350 [
'renameIndex',
'sites',
'site_group',
'sites_group' ],
351 [
'renameIndex',
'sites',
'site_source',
'sites_source' ],
352 [
'renameIndex',
'sites',
'site_language',
'sites_language' ],
353 [
'renameIndex',
'sites',
'site_protocol',
'sites_protocol' ],
354 [
'renameIndex',
'sites',
'site_domain',
'sites_domain' ],
355 [
'renameIndex',
'sites',
'site_forward',
'sites_forward' ],
356 [
'dropFkey',
'user_newtalk',
'user_id' ],
357 [
'renameIndex',
'user_newtalk',
'user_newtalk_id',
'un_user_id' ],
358 [
'renameIndex',
'user_newtalk',
'user_newtalk_ip',
'un_user_ip' ],
359 [
'changeField',
'interwiki',
'iw_prefix',
'VARCHAR(32)',
'' ],
360 [
'changeField',
'interwiki',
'iw_wikiid',
'VARCHAR(64)',
'' ],
361 [
'dropFkey',
'protected_titles',
'pt_user' ],
362 [
'changeNullableField',
'protected_titles',
'pt_user',
'NOT NULL',
true ],
363 [
'changeNullableField',
'protected_titles',
'pt_expiry',
'NOT NULL',
true ],
364 [
'changeField',
'protected_titles',
'pt_reason_id',
'BIGINT',
'' ],
365 [
'dropDefault',
'protected_titles',
'pt_create_perm' ],
366 [
'dropFkey',
'externallinks',
'el_from' ],
367 [
'setDefault',
'externallinks',
'el_from', 0 ],
368 [
'changeField',
'externallinks',
'el_index_60',
'TEXT',
'' ],
369 [
'renameIndex',
'externallinks',
'externallinks_from_to',
'el_from' ],
370 [
'renameIndex',
'externallinks',
'externallinks_index',
'el_index' ],
371 [
'addPgIndex',
'externallinks',
'el_to',
'(el_to, el_from)' ],
372 [
'dropSequence',
'ip_changes',
'ip_changes_ipc_rev_id_seq' ],
373 [
'changeField',
'ip_changes',
'ipc_hex',
'TEXT',
"ipc_hex::TEXT DEFAULT ''" ],
374 [
'setDefault',
'ip_changes',
'ipc_rev_id', 0 ],
375 [
'changeField',
'revision_comment_temp',
'revcomment_comment_id',
'BIGINT',
'' ],
376 [
'renameIndex',
'watchlist',
'namespace_title',
'wl_namespace_title' ],
377 [
'dropFkey',
'page_props',
'pp_page' ],
379 [
'changePrimaryKey',
'page_props', [
'pp_page',
'pp_propname' ],
'page_props_pk' ],
380 [
'setDefault',
'job',
'job_cmd',
'' ],
381 [
'changeField',
'job',
'job_namespace',
'INTEGER',
'' ],
382 [
'dropPgIndex',
'job',
'job_cmd_namespace_title' ],
383 [
'addPgIndex',
'job',
'job_cmd',
'(job_cmd, job_namespace, job_title, job_params)' ],
384 [
'renameIndex',
'job',
'job_timestamp_idx',
'job_timestamp' ],
385 [
'changeField',
'slot_roles',
'role_id',
'INTEGER',
'' ],
386 [
'changeField',
'content_models',
'model_id',
'INTEGER',
'' ],
387 [
'renameIndex',
'page',
'page_len_idx',
'page_len' ],
388 [
'renameIndex',
'page',
'page_random_idx',
'page_random' ],
389 [
'renameIndex',
'page',
'page_unique_name',
'page_name_title' ],
390 [
'addPGIndex',
'page',
'page_redirect_namespace_len',
'(page_is_redirect, page_namespace, page_len)' ],
391 [
'dropFkey',
'categorylinks',
'cl_from' ],
392 [
'setDefault',
'categorylinks',
'cl_from', 0 ],
393 [
'setDefault',
'categorylinks',
'cl_to',
'' ],
394 [
'setDefault',
'categorylinks',
'cl_sortkey',
'' ],
395 [
'setDefault',
'categorylinks',
'cl_collation',
'' ],
396 [
'changeNullableField',
'categorylinks',
'cl_sortkey',
'NOT NULL',
true ],
397 [
'addIndex',
'categorylinks',
'categorylinks_pkey',
'patch-categorylinks-pk.sql' ],
398 [
'addPgIndex',
'categorylinks',
'cl_timestamp',
'(cl_to, cl_timestamp)' ],
399 [
'addPgIndex',
'categorylinks',
'cl_collation_ext',
'(cl_collation, cl_to, cl_type, cl_from)' ],
400 [
'checkIndex',
'cl_sortkey', [
401 [
'cl_to',
'text_ops',
'btree', 1 ],
402 [
'cl_type',
'text_ops',
'btree', 1 ],
403 [
'cl_sortkey',
'text_ops',
'btree', 1 ],
404 [
'cl_from',
'text_ops',
'btree', 1 ],
406 'CREATE INDEX cl_sortkey ON categorylinks (cl_to, cl_type, cl_sortkey, cl_from)' ],
407 [
'renameIndex',
'logging',
'logging_type_name',
'type_time' ],
408 [
'renameIndex',
'logging',
'logging_actor_time_backwards',
'actor_time' ],
409 [
'renameIndex',
'logging',
'logging_page_time',
'page_time' ],
410 [
'renameIndex',
'logging',
'logging_times',
'times' ],
411 [
'renameIndex',
'logging',
'logging_actor_type_time',
'log_actor_type_time' ],
412 [
'renameIndex',
'logging',
'logging_page_id_time',
'log_page_id_time' ],
413 [
'renameIndex',
'logging',
'logging_type_action',
'log_type_action' ],
414 [
'changeNullableField',
'logging',
'log_params',
'NOT NULL',
true ],
415 [
'setDefault',
'logging',
'log_action',
'' ],
416 [
'setDefault',
'logging',
'log_type',
'' ],
417 [
'setDefault',
'logging',
'log_title',
'' ],
418 [
'setDefault',
'logging',
'log_timestamp',
'1970-01-01 00:00:00+00' ],
419 [
'changeField',
'logging',
'log_actor',
'BIGINT',
'' ],
420 [
'changeField',
'logging',
'log_comment_id',
'BIGINT',
'' ],
421 [
'changeField',
'logging',
'log_namespace',
'INT',
'log_namespace::INT DEFAULT 0' ],
422 [
'dropPgIndex',
'logging',
'logging_actor_time' ],
423 [
'changeField',
'uploadstash',
'us_key',
'VARCHAR(255)',
'' ],
424 [
'changeField',
'uploadstash',
'us_orig_path',
'VARCHAR(255)',
'' ],
425 [
'changeField',
'uploadstash',
'us_path',
'VARCHAR(255)',
'' ],
426 [
'changeField',
'uploadstash',
'us_source_type',
'VARCHAR(50)',
'' ],
427 [
'changeField',
'uploadstash',
'us_props',
'TEXT',
'' ],
428 [
'changeField',
'uploadstash',
'us_status',
'VARCHAR(50)',
'' ],
429 [
'changeField',
'uploadstash',
'us_sha1',
'VARCHAR(31)',
'' ],
430 [
'changeField',
'uploadstash',
'us_mime',
'VARCHAR(255)',
'' ],
431 [
'changeNullableField',
'uploadstash',
'us_key',
'NOT NULL',
true ],
432 [
'changeNullableField',
'uploadstash',
'us_user',
'NOT NULL',
true ],
433 [
'changeNullableField',
'uploadstash',
'us_orig_path',
'NOT NULL',
true ],
434 [
'changeNullableField',
'uploadstash',
'us_path',
'NOT NULL',
true ],
435 [
'changeNullableField',
'uploadstash',
'us_timestamp',
'NOT NULL',
true ],
436 [
'changeNullableField',
'uploadstash',
'us_status',
'NOT NULL',
true ],
437 [
'changeNullableField',
'uploadstash',
'us_size',
'NOT NULL',
true ],
438 [
'changeNullableField',
'uploadstash',
'us_sha1',
'NOT NULL',
true ],
439 [
'renameIndex',
'uploadstash',
'us_user_idx',
'us_user' ],
440 [
'renameIndex',
'uploadstash',
'us_key_idx',
'us_key' ],
441 [
'renameIndex',
'uploadstash',
'us_timestamp_idx',
'us_timestamp' ],
442 [
'renameIndex',
'user_properties',
'user_properties_property',
'up_property' ],
443 [
'renameIndex',
'sites',
'sites_global_key',
'site_global_key' ],
444 [
'renameIndex',
'sites',
'sites_type',
'site_type' ],
445 [
'renameIndex',
'sites',
'sites_group, ',
'site_group' ],
446 [
'renameIndex',
'sites',
'sites_source',
'site_source' ],
447 [
'renameIndex',
'sites',
'sites_language',
'site_language' ],
448 [
'renameIndex',
'sites',
'sites_protocol',
'site_protocol' ],
449 [
'renameIndex',
'sites',
'sites_domain',
'site_domain' ],
450 [
'renameIndex',
'sites',
'sites_forward',
'site_forward' ],
451 [
'renameIndex',
'logging',
'type_name',
'log_type_time' ],
452 [
'renameIndex',
'logging',
'actor_time',
'log_actor_time' ],
453 [
'renameIndex',
'logging',
'page_time',
'log_page_time' ],
454 [
'renameIndex',
'logging',
'times',
'log_times' ],
455 [
'setDefault',
'filearchive',
'fa_name',
'' ],
456 [
'setDefault',
'filearchive',
'fa_archive_name',
'' ],
457 [
'setDefault',
'filearchive',
'fa_storage_key',
'' ],
458 [
'dropFkey',
'filearchive',
'fa_deleted_user' ],
459 [
'changeField',
'filearchive',
'fa_deleted_reason_id',
'BIGINT',
'' ],
460 [
'changeField',
'filearchive',
'fa_metadata',
'TEXT',
'' ],
461 [
'changeField',
'filearchive',
'fa_bits',
'INTEGER',
'' ],
462 [
'changeField',
'filearchive',
'fa_description_id',
'BIGINT',
'' ],
463 [
'changeField',
'filearchive',
'fa_actor',
'BIGINT',
'' ],
464 [
'renameIndex',
'filearchive',
'fa_name_time',
'fa_name' ],
465 [
'renameIndex',
'filearchive',
'fa_dupe',
'fa_storage_group' ],
466 [
'renameIndex',
'filearchive',
'fa_notime',
'fa_deleted_timestamp' ],
467 [
'dropPgIndex',
'filearchive',
'fa_nouser' ],
468 [
'addPgIndex',
'filearchive',
'fa_actor_timestamp',
'(fa_actor, fa_timestamp)' ],
469 [
'addPgIndex',
'ipblocks',
'ipb_expiry',
'(ipb_expiry)' ],
470 [
'addPgIndex',
'ipblocks',
'ipb_timestamp',
'(ipb_timestamp)' ],
471 [
'renameIndex',
'text',
'pagecontent_pkey',
'text_pkey' ],
472 [
'changeNullableField',
'text',
'old_text',
'NOT NULL',
true ],
473 [
'changeNullableField',
'text',
'old_flags',
'NOT NULL',
true ],
474 [
'setDefault',
'oldimage',
'oi_name',
'' ],
475 [
'setDefault',
'oldimage',
'oi_archive_name',
'' ],
476 [
'setDefault',
'oldimage',
'oi_size', 0 ],
477 [
'setDefault',
'oldimage',
'oi_width', 0 ],
478 [
'setDefault',
'oldimage',
'oi_height', 0 ],
479 [
'setDefault',
'oldimage',
'oi_bits', 0 ],
480 [
'setDefault',
'oldimage',
'oi_name',
'' ],
481 [
'changeField',
'oldimage',
'oi_bits',
'INTEGER',
'' ],
482 [
'changeField',
'oldimage',
'oi_description_id',
'BIGINT',
'' ],
483 [
'changeField',
'oldimage',
'oi_actor',
'BIGINT',
'' ],
484 [
'changeField',
'oldimage',
'oi_metadata',
'TEXT',
'' ],
485 [
'dropDefault',
'oldimage',
'oi_metadata' ],
486 [
'changeNullableField',
'oldimage',
'oi_minor_mime',
'NOT NULL',
true ],
487 [
'changeNullableField',
'oldimage',
'oi_minor_mime',
'NOT NULL',
true ],
488 [
'dropFkey',
'oldimage',
'oi_name' ],
489 [
'addPgIndex',
'oldimage',
'oi_actor_timestamp',
'(oi_actor, oi_timestamp)' ],
490 [
'dropPgIndex',
'recentchanges',
'rc_timestamp_bot' ],
491 [
'addPgIndex',
'recentchanges',
'rc_ns_actor',
'(rc_namespace, rc_actor)' ],
492 [
'addPgIndex',
'recentchanges',
'rc_actor',
'(rc_actor, rc_timestamp)' ],
493 [
'dropIndex',
'objectcache',
'keyname',
'patch-objectcache_keyname-pk.sql' ],
494 [
'changeField',
'objectcache',
'value',
'TEXT',
'' ],
495 [
'changeNullableField',
'objectcache',
'value',
'NULL',
true ],
496 [
'dropFkey',
'ipblocks',
'ipb_user' ],
497 [
'dropFkey',
'ipblocks',
'ipb_parent_block_id' ],
498 [
'setDefault',
'ipblocks',
'ipb_user', 0 ],
499 [
'changeNullableField',
'ipblocks',
'ipb_user',
'NOT NULL',
true ],
500 [
'changeNullableField',
'ipblocks',
'ipb_range_start',
'NOT NULL',
true ],
501 [
'changeNullableField',
'ipblocks',
'ipb_range_end',
'NOT NULL',
true ],
502 [
'changeField',
'ipblocks',
'ipb_by_actor',
'BIGINT',
'' ],
503 [
'changeField',
'ipblocks',
'ipb_reason_id',
'BIGINT',
'' ],
504 [
'renameIndex',
'archive',
'archive_name_title_timestamp',
'ar_name_title_timestamp' ],
505 [
'dropPgIndex',
'archive',
'archive_actor' ],
506 [
'addPgIndex',
'archive',
'ar_actor_timestamp',
'(ar_actor,ar_timestamp)' ],
507 [
'setDefault',
'image',
'img_name',
'' ],
508 [
'setDefault',
'image',
'img_size', 0 ],
509 [
'setDefault',
'image',
'img_width', 0 ],
510 [
'setDefault',
'image',
'img_height', 0 ],
511 [
'setDefault',
'image',
'img_bits', 0 ],
512 [
'changeField',
'image',
'img_bits',
'INTEGER',
'' ],
513 [
'changeField',
'image',
'img_description_id',
'BIGINT',
'' ],
514 [
'changeField',
'image',
'img_actor',
'BIGINT',
'' ],
515 [
'changeField',
'image',
'img_metadata',
'TEXT',
'' ],
516 [
'dropDefault',
'image',
'img_metadata' ],
517 [
'changeNullableField',
'image',
'img_major_mime',
'NOT NULL',
true ],
518 [
'changeNullableField',
'image',
'img_minor_mime',
'NOT NULL',
true ],
519 [
'changeNullableField',
'image',
'img_timestamp',
'NOT NULL',
true ],
520 [
'renameIndex',
'image',
'img_size_idx',
'img_size' ],
521 [
'renameIndex',
'image',
'img_timestamp_idx',
'img_timestamp' ],
522 [
'addPgIndex',
'image',
'img_actor_timestamp',
'(img_actor, img_timestamp)' ],
523 [
'addPgIndex',
'image',
'img_media_mime',
'(img_media_type, img_major_mime, img_minor_mime)' ],
524 [
'renameIndex',
'site_identifiers',
'site_ids_site',
'si_site' ],
525 [
'renameIndex',
'site_identifiers',
'site_ids_key',
'si_key' ],
526 [
'changeField',
'recentchanges',
'rc_actor',
'BIGINT',
'' ],
527 [
'changeField',
'recentchanges',
'rc_comment_id',
'BIGINT',
'' ],
528 [
'changeField',
'recentchanges',
'rc_ip',
'TEXT',
'' ],
529 [
'changeField',
'recentchanges',
'rc_namespace',
'INTEGER',
'' ],
530 [
'setDefault',
'recentchanges',
'rc_title',
'' ],
531 [
'setDefault',
'recentchanges',
'rc_source',
'' ],
532 [
'setDefault',
'recentchanges',
'rc_ip',
'' ],
533 [
'setDefault',
'recentchanges',
'rc_namespace', 0 ],
534 [
'setDefault',
'recentchanges',
'rc_cur_id', 0 ],
535 [
'setDefault',
'recentchanges',
'rc_this_oldid', 0 ],
536 [
'setDefault',
'recentchanges',
'rc_last_oldid', 0 ],
537 [
'changeNullableField',
'recentchanges',
'rc_cur_id',
'NOT NULL',
true ],
538 [
'changeNullableField',
'recentchanges',
'rc_ip',
'NOT NULL',
true ],
539 [
'renameIndex',
'recentchanges',
'new_name_timestamp',
'rc_new_name_timestamp',
false,
540 'patch-recentchanges-rc_new_name_timestamp.sql' ],
541 [
'changeField',
'archive',
'ar_namespace',
'INTEGER',
'' ],
542 [
'setDefault',
'archive',
'ar_namespace', 0 ],
543 [
'setDefault',
'archive',
'ar_title',
'' ],
544 [
'changeField',
'archive',
'ar_comment_id',
'BIGINT',
'' ],
545 [
'changeField',
'archive',
'ar_actor',
'BIGINT',
'' ],
546 [
'renameIndex',
'user',
'user_email_token_idx',
'user_email_token' ],
547 [
'addPgIndex',
'user',
'user_email',
'(user_email)' ],
548 [
'addPgIndex',
'user',
'user_name',
'(user_name)',
true ],
549 [
'changeField',
'page',
'page_namespace',
'INTEGER',
'' ],
550 [
'changeNullableField',
'page',
'page_touched',
'NOT NULL',
true ],
551 [
'changeField',
'page',
'page_random',
'FLOAT',
'' ],
552 [
'renameIndex',
'revision',
'revision_unique',
'rev_page_id' ],
553 [
'renameIndex',
'revision',
'rev_timestamp_idx',
'rev_timestamp' ],
554 [
'addPgIndex',
'revision',
'rev_page_timestamp',
'(rev_page,rev_timestamp)' ],
555 [
'changeNullableField',
'user',
'user_touched',
'NOT NULL',
true ],
558 [
'setDefault',
'user',
'user_name',
'' ],
559 [
'setDefault',
'user',
'user_token',
'' ],
560 [
'setDefault',
'user',
'user_real_name',
'' ],
561 [
'setDefault',
'user',
'user_email',
'' ],
562 [
'setDefault',
'user',
'user_newpassword',
'' ],
563 [
'setDefault',
'user',
'user_password',
'' ],
564 [
'changeNullableField',
'user',
'user_token',
'NOT NULL',
true ],
565 [
'changeNullableField',
'user',
'user_real_name',
'NOT NULL',
true ],
566 [
'changeNullableField',
'user',
'user_email',
'NOT NULL',
true ],
567 [
'changeNullableField',
'user',
'user_newpassword',
'NOT NULL',
true ],
568 [
'changeNullableField',
'user',
'user_password',
'NOT NULL',
true ],
569 [
'dropDefault',
'user',
'user_email' ],
570 [
'dropDefault',
'user',
'user_newpassword' ],
571 [
'dropDefault',
'user',
'user_password' ],
572 [
'dropConstraint',
'user',
'user_name',
'unique' ],
573 [
'addField',
'objectcache',
'modtoken',
'patch-objectcache-modtoken.sql' ],
574 [
'dropFkey',
'revision',
'rev_page' ],
575 [
'changeNullableField',
'revision',
'rev_page',
'NOT NULL',
true ],
576 [
'changeField',
'revision',
'rev_comment_id',
'BIGINT',
'rev_comment_id::BIGINT DEFAULT 0' ],
577 [
'changeField',
'revision',
'rev_actor',
'BIGINT',
'rev_actor::BIGINT DEFAULT 0' ],
578 [
'checkIndex',
'rev_page_id', [
579 [
'rev_page',
'int4_ops',
'btree', 1 ],
580 [
'rev_id',
'int4_ops',
'btree', 1 ],
582 'CREATE INDEX rev_page_id ON revision (rev_page,rev_id)' ],
583 [
'addTable',
'searchindex',
'patch-searchindex-table.sql' ],
584 [
'addPgIndex',
'oldimage',
'oi_timestamp',
'(oi_timestamp)' ],
585 [
'renameIndex',
'page',
'name_title',
'page_name_title' ],
586 [
'renameIndex',
'change_tag',
'change_tag_rc_tag_id',
'ct_rc_tag_id' ],
587 [
'renameIndex',
'change_tag',
'change_tag_log_tag_id',
'ct_log_tag_id' ],
588 [
'renameIndex',
'change_tag',
'change_tag_rev_tag_id',
'ct_rev_tag_id' ],
589 [
'renameIndex',
'change_tag',
'change_tag_tag_id_id',
'ct_tag_id_id' ],
592 [
'doConvertDjvuMetadata' ],
593 [
'dropPgField',
'page_restrictions',
'pr_user' ],
594 [
'addTable',
'linktarget',
'patch-linktarget.sql' ],
595 [
'dropIndex',
'revision',
'rev_page_id',
'patch-drop-rev_page_id.sql' ],
596 [
'addField',
'templatelinks',
'tl_target_id',
'patch-templatelinks-target_id.sql' ],
599 [
'addTable',
'user_autocreate_serial',
'patch-user_autocreate_serial.sql' ],
600 [
'runMaintenance', MigrateRevisionActorTemp::class ],
601 [
'dropTable',
'revision_actor_temp' ],
602 [
'runMaintenance', UpdateRestrictions::class ],
603 [
'dropPgField',
'page',
'page_restrictions' ],
604 [
'migrateTemplatelinks' ],
605 [
'changeNullableField',
'templatelinks',
'tl_target_id',
'NOT NULL',
true ],
606 [
'changePrimaryKey',
'templatelinks', [
'tl_from',
'tl_target_id' ] ],
607 [
'dropField',
'templatelinks',
'tl_title',
'patch-templatelinks-drop-tl_title.sql' ],
613SELECT attname, attnum FROM pg_namespace, pg_class, pg_attribute
614 WHERE pg_class.relnamespace = pg_namespace.oid
615 AND attrelid=pg_class.oid AND attnum > 0
616 AND relname=%s AND nspname=%s
618 $res = $this->db->query(
620 $this->db->addQuotes( $table ),
621 $this->db->addQuotes( $this->db->getCoreSchema() )
630 foreach (
$res as $r ) {
644SELECT indkey, indrelid FROM pg_namespace, pg_class, pg_index
646 AND pg_class.relnamespace = pg_namespace.oid
648 AND indexrelid=pg_class.oid
650 $res = $this->db->query(
653 $this->db->addQuotes( $this->db->getCoreSchema() ),
654 $this->db->addQuotes( $idx )
661 $r =
$res->fetchRow();
667 $relid = intval( $r[1] );
668 $indkeys = explode(
' ', $indkey );
671 foreach ( $indkeys as $rid ) {
673SELECT attname FROM pg_class, pg_attribute
674 WHERE attrelid=$relid
676 AND attrelid=pg_class.oid
678 $r2 = $this->db->query( sprintf( $query, $rid ), __METHOD__ );
682 $row2 = $r2->fetchRow();
686 $colnames[] = $row2[0];
694SELECT confdeltype FROM pg_constraint, pg_namespace
695 WHERE connamespace=pg_namespace.oid
699 $r = $this->db->query(
702 $this->db->addQuotes( $this->db->getCoreSchema() ),
703 $this->db->addQuotes( $fkey )
707 $row = $r->fetchRow();
717SELECT definition FROM pg_rules
718 WHERE schemaname = %s
722 $r = $this->db->query(
725 $this->db->addQuotes( $this->db->getCoreSchema() ),
726 $this->db->addQuotes( $table ),
727 $this->db->addQuotes( $rule )
731 $row = $r->fetchRow();
741 if ( !$this->db->sequenceExists( $ns ) ) {
742 $this->
output(
"Creating sequence $ns\n" );
743 if ( $pkey !==
false ) {
744 $table = $this->db->addIdentifierQuotes( $table );
745 $this->db->query(
"CREATE SEQUENCE $ns OWNED BY $table.$pkey", __METHOD__ );
746 $this->
setDefault( $table, $pkey,
'"nextval"(\'"' . $ns .
'"\'::"regclass")' );
748 $this->db->query(
"CREATE SEQUENCE $ns", __METHOD__ );
754 if ( $this->db->sequenceExists( $ns ) ) {
755 $this->
output(
"Dropping sequence $ns\n" );
756 $this->db->query(
"DROP SEQUENCE $ns CASCADE", __METHOD__ );
761 if ( $this->db->sequenceExists( $new ) ) {
762 $this->
output(
"...sequence $new already exists.\n" );
766 if ( $this->db->sequenceExists( $old ) ) {
767 $this->
output(
"Renaming sequence $old to $new\n" );
768 $this->db->query(
"ALTER SEQUENCE $old RENAME TO $new", __METHOD__ );
773 if ( $this->db->sequenceExists( $seq ) ) {
774 $this->
output(
"Setting sequence $seq owner to $table.$pkey\n" );
775 $table = $this->db->addIdentifierQuotes( $table );
776 $this->db->query(
"ALTER SEQUENCE $seq OWNED BY $table.$pkey", __METHOD__ );
781 if ( $this->db->tableExists( $old, __METHOD__ ) ) {
782 $this->
output(
"Renaming table $old to $new\n" );
783 $old = $this->db->addIdentifierQuotes( $old );
784 $new = $this->db->addIdentifierQuotes( $new );
785 $this->db->query(
"ALTER TABLE $old RENAME TO $new", __METHOD__ );
786 if ( $patch !==
false ) {
793 $table, $old, $new, $skipBothIndexExistWarning =
false, $a =
false, $b =
false
796 if ( !$this->db->tableExists( $table, __METHOD__ ) ) {
797 $this->
output(
"...skipping: '$table' table doesn't exist yet.\n" );
803 if ( $this->db->indexExists( $table, $new, __METHOD__ ) ) {
804 $this->
output(
"...index $new already set on $table table.\n" );
805 if ( !$skipBothIndexExistWarning
806 && $this->db->indexExists( $table, $old, __METHOD__ )
808 $this->
output(
"...WARNING: $old still exists, despite it has been " .
809 "renamed into $new (which also exists).\n" .
810 " $old should be manually removed if not needed anymore.\n" );
817 if ( !$this->db->indexExists( $table, $old, __METHOD__ ) ) {
818 $this->
output(
"...skipping: index $old doesn't exist.\n" );
823 $this->db->query(
"ALTER INDEX $old RENAME TO $new", __METHOD__ );
828 $fi = $this->db->fieldInfo( $table, $field );
829 if ( $fi ===
null ) {
830 $this->
output(
"...$table table does not contain $field field.\n" );
832 $this->
output(
"Dropping column '$table.$field'\n" );
833 $table = $this->db->addIdentifierQuotes( $table );
834 $this->db->query(
"ALTER TABLE $table DROP COLUMN $field", __METHOD__ );
839 $fi = $this->db->fieldInfo( $table, $field );
840 if ( $fi !==
null ) {
841 $this->
output(
"...column '$table.$field' already exists\n" );
843 $this->
output(
"Adding column '$table.$field'\n" );
844 $table = $this->db->addIdentifierQuotes( $table );
845 $this->db->query(
"ALTER TABLE $table ADD $field $type", __METHOD__ );
849 protected function changeField( $table, $field, $newtype, $default ) {
850 $fi = $this->db->fieldInfo( $table, $field );
851 if ( $fi ===
null ) {
852 $this->
output(
"...ERROR: expected column $table.$field to exist\n" );
856 if ( $fi->type() === strtolower( $newtype ) ) {
857 $this->
output(
"...column '$table.$field' is already of type '$newtype'\n" );
859 $this->
output(
"Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
860 $table = $this->db->addIdentifierQuotes( $table );
861 $sql =
"ALTER TABLE $table ALTER $field TYPE $newtype";
862 if ( strlen( $default ) ) {
864 if ( preg_match(
'/DEFAULT (.+)/', $default,
$res ) ) {
865 $sqldef =
"ALTER TABLE $table ALTER $field SET DEFAULT $res[1]";
866 $this->db->query( $sqldef, __METHOD__ );
867 $default = preg_replace(
'/\s*DEFAULT .+/',
'', $default );
869 $sql .=
" USING $default";
871 $this->db->query( $sql, __METHOD__ );
876 # # For a cache table, empty it if the field needs to be changed, because the old contents
877 # # may be corrupted. If the column is already the desired type, refrain from purging.
878 $fi = $this->db->fieldInfo( $table, $field );
879 if ( $fi ===
null ) {
880 $this->
output(
"...ERROR: expected column $table.$field to exist\n" );
884 if ( $fi->type() === $newtype ) {
885 $this->
output(
"...column '$table.$field' is already of type '$newtype'\n" );
887 $this->
output(
"Purging data from cache table '$table'\n" );
888 $table = $this->db->addIdentifierQuotes( $table );
889 $this->db->query(
"DELETE from $table", __METHOD__ );
890 $this->
output(
"Changing column type of '$table.$field' from '{$fi->type()}' to '$newtype'\n" );
891 $sql =
"ALTER TABLE $table ALTER $field TYPE $newtype";
892 if ( strlen( $default ) ) {
894 if ( preg_match(
'/DEFAULT (.+)/', $default,
$res ) ) {
895 $sqldef =
"ALTER TABLE $table ALTER $field SET DEFAULT $res[1]";
896 $this->db->query( $sqldef, __METHOD__ );
897 $default = preg_replace(
'/\s*DEFAULT .+/',
'', $default );
899 $sql .=
" USING $default";
901 $this->db->query( $sql, __METHOD__ );
906 $info = $this->db->fieldInfo( $table, $field );
907 if ( $info && $info->defaultValue() !== $default ) {
908 $this->
output(
"Changing '$table.$field' default value\n" );
909 $table = $this->db->addIdentifierQuotes( $table );
910 $this->db->query(
"ALTER TABLE $table ALTER $field SET DEFAULT "
911 . $this->db->addQuotes( $default ), __METHOD__ );
922 $info = $this->db->fieldInfo( $table, $field );
923 if ( $info->defaultValue() !==
false ) {
924 $this->
output(
"Removing '$table.$field' default value\n" );
925 $table = $this->db->addIdentifierQuotes( $table );
926 $this->db->query(
"ALTER TABLE $table ALTER $field DROP DEFAULT", __METHOD__ );
931 $fi = $this->db->fieldInfo( $table, $field );
932 if ( $fi ===
null ) {
935 if ( $fi->isNullable() ) {
936 # # It's NULL - does it need to be NOT NULL?
937 if ( $null ===
'NOT NULL' ) {
938 $this->
output(
"Changing '$table.$field' to not allow NULLs\n" );
939 $table = $this->db->addIdentifierQuotes( $table );
941 $this->db->query(
"UPDATE $table SET $field = DEFAULT WHERE $field IS NULL", __METHOD__ );
943 $this->db->query(
"ALTER TABLE $table ALTER $field SET NOT NULL", __METHOD__ );
945 $this->
output(
"...column '$table.$field' is already set as NULL\n" );
948 # # It's NOT NULL - does it need to be NULL?
949 if ( $null ===
'NULL' ) {
950 $this->
output(
"Changing '$table.$field' to allow NULLs\n" );
951 $table = $this->db->addIdentifierQuotes( $table );
952 $this->db->query(
"ALTER TABLE $table ALTER $field DROP NOT NULL", __METHOD__ );
954 $this->
output(
"...column '$table.$field' is already set as NOT NULL\n" );
960 if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
961 $this->
output(
"...index '$index' on table '$table' already exists\n" );
963 $this->
output(
"Creating index '$index' on table '$table' $type\n" );
964 $table = $this->db->addIdentifierQuotes( $table );
965 $unique = $unique ?
'UNIQUE' :
'';
966 $this->db->query(
"CREATE $unique INDEX $index ON $table $type", __METHOD__ );
971 if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
972 $this->
output(
"...index '$index' on table '$table' already exists\n" );
973 } elseif ( preg_match(
'/^\(/',
$type ) ) {
974 $this->
output(
"Creating index '$index' on table '$table'\n" );
975 $table = $this->db->addIdentifierQuotes( $table );
976 $this->db->query(
"CREATE INDEX $index ON $table $type", __METHOD__ );
978 $this->
applyPatch(
$type,
true,
"Creating index '$index' on table '$table'" );
989 $row = $this->db->selectRow(
991 't' =>
'pg_catalog.pg_type',
992 'n' =>
'pg_catalog.pg_namespace',
993 'e' =>
'pg_catalog.pg_enum',
995 [
't.typname',
't.typtype',
'e.enumlabel' ],
997 't.typname' =>
$type,
998 'n.nspname' => $this->db->getCoreSchema(),
1003 'n' => [
'JOIN',
't.typnamespace = n.oid' ],
1004 'e' => [
'LEFT JOIN', [
'e.enumtypid = t.oid',
'e.enumlabel' => $value ] ],
1009 $this->
output(
"...Type $type does not exist, skipping modify enum.\n" );
1010 } elseif ( $row->typtype !==
'e' ) {
1011 $this->
output(
"...Type $type does not seem to be an enum, skipping modify enum.\n" );
1012 } elseif ( $row->enumlabel === $value ) {
1013 $this->
output(
"...Enum type $type already contains value '$value'.\n" );
1015 $this->
output(
"...Adding value '$value' to enum type $type.\n" );
1016 $etype = $this->db->addIdentifierQuotes(
$type );
1017 $evalue = $this->db->addQuotes( $value );
1018 $this->db->query(
"ALTER TYPE $etype ADD VALUE $evalue", __METHOD__ );
1023 $fi = $this->db->fieldInfo( $table, $field );
1024 if ( $fi ===
null ) {
1025 $this->
output(
"WARNING! Column '$table.$field' does not exist but it should! " .
1026 "Please report this.\n" );
1030 if ( $this->
dropConstraint( $table, $field,
'foreignkey', $fi->conname() ) ) {
1031 $this->
output(
"Dropping foreign key constraint on '$table.$field'\n" );
1033 $this->
output(
"...foreign key constraint on '$table.$field' already does not exist\n" );
1038 $fi = $this->db->fieldInfo( $table, $field );
1039 if ( $fi ===
null ) {
1040 $this->
output(
"WARNING! Column '$table.$field' does not exist but it should! " .
1041 "Please report this.\n" );
1045 if ( $fi->is_deferred() && $fi->is_deferrable() ) {
1048 $this->
output(
"Altering column '$table.$field' to be DEFERRABLE INITIALLY DEFERRED\n" );
1050 $conname = $fi->conname();
1051 $conclause =
"CONSTRAINT \"$conname\"";
1053 if ( !$this->
dropConstraint( $table, $field,
'foreignkey', $conname ) ) {
1054 $this->
output(
"Column '$table.$field' does not have a foreign key " .
1055 "constraint, will be added\n" );
1060 "ALTER TABLE $table ADD $conclause " .
1061 "FOREIGN KEY ($field) REFERENCES $clause DEFERRABLE INITIALLY DEFERRED";
1062 $this->db->query(
$command, __METHOD__ );
1066 if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) {
1067 $this->
output(
"Dropping obsolete index '$index'\n" );
1068 $this->db->query(
"DROP INDEX \"" . $index .
"\"", __METHOD__ );
1073 $pu = $this->db->indexAttributes( $index );
1074 if ( !empty( $pu ) && $pu != $should_be ) {
1075 $this->
output(
"Dropping obsolete version of index '$index'\n" );
1076 $this->db->query(
"DROP INDEX \"" . $index .
"\"", __METHOD__ );
1079 $this->
output(
"...no need to drop index '$index'\n" );
1082 if ( empty( $pu ) ) {
1083 $this->
output(
"Creating index '$index'\n" );
1084 $this->db->query( $good_def, __METHOD__ );
1086 $this->
output(
"...index '$index' exists\n" );
1092 $result = $this->db->query(
1093 "SELECT a.attname as column " .
1094 "FROM pg_index i " .
1095 "JOIN pg_attribute a ON a.attrelid = i.indrelid " .
1096 "AND a.attnum = ANY(i.indkey) " .
1097 "WHERE i.indrelid = '\"$table\"'::regclass " .
1098 "AND i.indisprimary",
1101 $currentColumns = [];
1102 foreach ( $result as $row ) {
1103 $currentColumns[] = $row->column;
1106 if ( $currentColumns == $shouldBe ) {
1107 $this->
output(
"...no need to change primary key of '$table'\n" );
1113 $table = $this->db->addIdentifierQuotes( $table );
1115 "ALTER TABLE $table" .
1116 " ADD PRIMARY KEY (" . implode(
',', $shouldBe ) .
');',
1133 if ( $conname ===
null ) {
1134 if (
$type ==
'primary' ) {
1135 $conname =
"{$table}_pkey";
1137 $map = [
'unique' =>
'key',
'check' =>
'check',
'foreignkey' =>
'fkey' ];
1138 $conname =
"{$table}_{$field}_{$map[$type]}";
1142 if ( $this->db->constraintExists( $table, $conname ) ) {
1143 $table = $this->db->addIdentifierQuotes( $table );
1145 "ALTER TABLE $table DROP CONSTRAINT $conname;",
Class for handling database updates.
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)
changePrimaryKey( $table, $shouldBe, $constraintName=null)
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.
dropSequence( $table, $ns)
addPgExtIndex( $table, $index, $type)
addSequence( $table, $pkey, $ns)
addPgEnumValue( $type, $value)
Add a value to an existing PostgreSQL enum type.
dropPgField( $table, $field)
renameSequence( $old, $new)
dropPgIndex( $table, $index)
setDefault( $table, $field, $default)
addPgField( $table, $field, $type)
setSequenceOwner( $table, $pkey, $seq)
dropFkey( $table, $field)
dropConstraint( $table, $field, $type, $conname=null)
Drop generic constraint.
changeFkeyDeferrable( $table, $field, $clause)
checkIndex( $index, $should_be, $good_def)
changeFieldPurgeTable( $table, $field, $newtype, $default)
addPgIndex( $table, $index, $type, $unique=false)
Postgres database abstraction layer.