2010-07-20 22:28:50 +00:00
|
|
|
<?php
|
2010-08-21 18:20:09 +00:00
|
|
|
/**
|
|
|
|
|
* Sqlite-specific updater.
|
|
|
|
|
*
|
2012-05-06 05:50:15 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2010-08-21 18:20:09 +00:00
|
|
|
* @file
|
2019-11-25 23:24:49 +00:00
|
|
|
* @ingroup Installer
|
2010-08-21 18:20:09 +00:00
|
|
|
*/
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-20 22:28:50 +00:00
|
|
|
/**
|
2010-07-29 18:36:39 +00:00
|
|
|
* Class for handling updates to Sqlite databases.
|
2010-12-16 11:20:39 +00:00
|
|
|
*
|
2019-11-25 23:24:49 +00:00
|
|
|
* @ingroup Installer
|
2010-07-29 18:36:39 +00:00
|
|
|
* @since 1.17
|
2020-05-04 20:16:03 +00:00
|
|
|
* @property Wikimedia\Rdbms\DatabaseSqlite $db
|
2010-07-20 22:28:50 +00:00
|
|
|
*/
|
|
|
|
|
class SqliteUpdater extends DatabaseUpdater {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-20 22:28:50 +00:00
|
|
|
protected function getCoreUpdateList() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2022-05-20 16:25:36 +00:00
|
|
|
// 1.35 but must come first
|
|
|
|
|
[ 'addField', 'revision', 'rev_actor', 'patch-revision-actor-comment-MCR.sql' ],
|
|
|
|
|
|
2018-05-04 17:29:53 +00:00
|
|
|
// 1.32
|
|
|
|
|
[ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
|
2016-11-18 20:42:11 +00:00
|
|
|
[ 'populateExternallinksIndex60' ],
|
|
|
|
|
[ 'modifyfield', 'externallinks', 'el_index_60',
|
|
|
|
|
'patch-externallinks-el_index_60-drop-default.sql' ],
|
2018-04-27 17:10:36 +00:00
|
|
|
[ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
|
2018-05-11 19:16:37 +00:00
|
|
|
[ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
|
2018-04-27 17:11:01 +00:00
|
|
|
[ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
|
2018-07-10 17:09:37 +00:00
|
|
|
[ 'populateContentTables' ],
|
2018-07-11 14:36:27 +00:00
|
|
|
[ 'addIndex', 'logging', 'log_type_action', 'patch-logging-log-type-action-index.sql' ],
|
|
|
|
|
[ 'dropIndex', 'logging', 'type_action', 'patch-logging-drop-type-action-index.sql' ],
|
2018-07-04 19:13:07 +00:00
|
|
|
[ 'renameIndex', 'interwiki', 'iw_prefix', 'PRIMARY', false, 'patch-interwiki-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'page_props', 'pp_page_propname', 'PRIMARY', false,
|
|
|
|
|
'patch-page_props-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'protected_titles', 'pt_namespace_title', 'PRIMARY', false,
|
|
|
|
|
'patch-protected_titles-fix-pk.sql' ],
|
|
|
|
|
[ 'renameIndex', 'site_identifiers', 'site_ids_type', 'PRIMARY', false,
|
|
|
|
|
'patch-site_identifiers-fix-pk.sql' ],
|
2018-08-02 19:12:07 +00:00
|
|
|
[ 'addIndex', 'recentchanges', 'rc_this_oldid', 'patch-recentchanges-rc_this_oldid-index.sql' ],
|
2018-08-28 17:44:03 +00:00
|
|
|
[ 'dropTable', 'transcache' ],
|
2018-08-28 21:32:55 +00:00
|
|
|
[ 'runMaintenance', PopulateChangeTagDef::class, 'maintenance/populateChangeTagDef.php' ],
|
2020-12-21 04:09:08 +00:00
|
|
|
[ 'dropIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-change_tag_rc_tag_id.sql' ],
|
2018-06-18 14:26:20 +00:00
|
|
|
[ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
|
|
|
|
|
[ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
|
2018-03-07 16:40:56 +00:00
|
|
|
[ 'migrateImageCommentTemp' ],
|
2018-11-14 20:20:11 +00:00
|
|
|
|
|
|
|
|
// 1.33
|
|
|
|
|
[ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
|
2018-12-12 19:20:42 +00:00
|
|
|
[ 'dropTable', 'valid_tag' ],
|
|
|
|
|
[ 'dropTable', 'tag_summary' ],
|
2019-01-04 18:55:11 +00:00
|
|
|
[ 'dropField', 'archive', 'ar_comment', 'patch-archive-drop-ar_comment.sql' ],
|
|
|
|
|
[ 'dropField', 'ipblocks', 'ipb_reason', 'patch-ipblocks-drop-ipb_reason.sql' ],
|
|
|
|
|
[ 'dropField', 'image', 'img_description', 'patch-image-drop-img_description.sql' ],
|
|
|
|
|
[ 'dropField', 'oldimage', 'oi_description', 'patch-oldimage-drop-oi_description.sql' ],
|
|
|
|
|
[ 'dropField', 'filearchive', 'fa_description', 'patch-filearchive-drop-fa_description.sql' ],
|
|
|
|
|
[ 'dropField', 'recentchanges', 'rc_comment', 'patch-recentchanges-drop-rc_comment.sql' ],
|
|
|
|
|
[ 'dropField', 'logging', 'log_comment', 'patch-logging-drop-log_comment.sql' ],
|
|
|
|
|
[ 'dropField', 'protected_titles', 'pt_reason', 'patch-protected_titles-drop-pt_reason.sql' ],
|
2019-07-23 17:40:52 +00:00
|
|
|
|
|
|
|
|
// 1.34
|
|
|
|
|
[ 'dropField', 'archive', 'ar_user', 'patch-archive-drop-ar_user.sql' ],
|
|
|
|
|
[ 'dropField', 'ipblocks', 'ipb_by', 'patch-ipblocks-drop-ipb_by.sql' ],
|
|
|
|
|
[ 'dropField', 'image', 'img_user', 'patch-image-drop-img_user.sql' ],
|
|
|
|
|
[ 'dropField', 'oldimage', 'oi_user', 'patch-oldimage-drop-oi_user.sql' ],
|
|
|
|
|
[ 'dropField', 'filearchive', 'fa_user', 'patch-filearchive-drop-fa_user.sql' ],
|
|
|
|
|
[ 'dropField', 'recentchanges', 'rc_user', 'patch-recentchanges-drop-rc_user.sql' ],
|
|
|
|
|
[ 'dropField', 'logging', 'log_user', 'patch-logging-drop-log_user.sql' ],
|
2020-02-07 19:15:46 +00:00
|
|
|
|
|
|
|
|
// 1.35
|
|
|
|
|
[ 'addTable', 'watchlist_expiry', 'patch-watchlist_expiry.sql' ],
|
2020-03-20 03:53:52 +00:00
|
|
|
[ 'modifyfield', 'filearchive', 'fa_actor', 'patch-filearchive-drop-fa_actor-DEFAULT.sql' ],
|
|
|
|
|
[ 'modifyfield', 'recentchanges', 'rc_actor', 'patch-recentchanges-drop-rc_actor-DEFAULT.sql' ],
|
2020-03-18 23:33:48 +00:00
|
|
|
[ 'modifyfield', 'logging', 'log_actor', 'patch-logging-drop-log_actor-DEFAULT.sql' ],
|
|
|
|
|
[ 'modifyField', 'page', 'page_restrictions', 'patch-page_restrictions-null.sql' ],
|
2020-04-21 21:51:33 +00:00
|
|
|
[ 'renameIndex', 'ipblocks', 'ipb_address', 'ipb_address_unique', false,
|
|
|
|
|
'patch-ipblocks-rename-ipb_address.sql' ],
|
2019-11-21 20:47:13 +00:00
|
|
|
[ 'dropField', 'archive', 'ar_text_id', 'patch-archive-MCR.sql' ],
|
2020-05-04 20:16:03 +00:00
|
|
|
[ 'doFixIpbAddressUniqueIndex' ],
|
2020-07-20 00:30:37 +00:00
|
|
|
[ 'modifyField', 'actor', 'actor_name', 'patch-actor-actor_name-varbinary.sql' ],
|
2020-08-25 15:29:14 +00:00
|
|
|
|
|
|
|
|
// 1.36
|
2020-07-20 00:30:37 +00:00
|
|
|
[ 'modifyField', 'content', 'content_id', 'patch-content-content_id-fix_not_null.sql' ],
|
2020-08-09 19:05:37 +00:00
|
|
|
[ 'modifyField', 'redirect', 'rd_title', 'patch-redirect-rd_title-varbinary.sql' ],
|
2020-08-15 19:01:57 +00:00
|
|
|
[ 'modifyField', 'pagelinks', 'pl_title', 'patch-pagelinks-pl_title-varbinary.sql' ],
|
2020-08-22 12:57:42 +00:00
|
|
|
[ 'modifyField', 'templatelinks', 'tl_title', 'patch-templatelinks-tl_title-varbinary.sql' ],
|
2020-08-22 20:51:25 +00:00
|
|
|
[ 'modifyField', 'imagelinks', 'il_to', 'patch-imagelinks-il_to-varbinary.sql' ],
|
2020-08-29 17:00:04 +00:00
|
|
|
[ 'modifyField', 'langlinks', 'll_title', 'patch-langlinks-ll_title-varbinary.sql' ],
|
2020-08-29 17:25:15 +00:00
|
|
|
[ 'modifyField', 'iwlinks', 'iwl_title', 'patch-iwlinks-iwl_title-varbinary.sql' ],
|
2020-09-05 18:33:21 +00:00
|
|
|
[ 'modifyField', 'category', 'cat_title', 'patch-category-cat_title-varbinary.sql' ],
|
2020-09-26 13:39:59 +00:00
|
|
|
[ 'modifyField', 'querycache', 'qc_title', 'patch-querycache-qc_title-varbinary.sql' ],
|
2020-09-26 14:39:53 +00:00
|
|
|
[ 'modifyField', 'querycachetwo', 'qcc_title', 'patch-querycachetwo-qcc_title-varbinary.sql' ],
|
2020-10-18 09:43:04 +00:00
|
|
|
[ 'modifyField', 'watchlist', 'wl_title', 'patch-watchlist-wl_title-varbinary.sql' ],
|
2020-10-27 05:55:50 +00:00
|
|
|
[ 'modifyField', 'protected_titles', 'pt_title', 'patch-protected_titles-pt_title-varbinary.sql' ],
|
|
|
|
|
[ 'modifyField', 'protected_titles', 'pt_expiry', 'patch-protected_titles-pt_expiry-drop-default.sql' ],
|
2020-11-10 07:48:11 +00:00
|
|
|
[ 'modifyField', 'ip_changes', 'ipc_rev_timestamp', 'patch-ip_changes-pc_rev_timestamp-drop-default.sql' ],
|
2020-11-16 14:24:24 +00:00
|
|
|
[ 'renameIndex', 'watchlist', 'namespace_title', 'wl_namespace_title', false,
|
|
|
|
|
'patch-watchlist-namespace_title-rename-index.sql' ],
|
2020-11-18 05:50:39 +00:00
|
|
|
[ 'modifyField', 'job', 'job_title', 'patch-job-job_title-varbinary.sql' ],
|
2020-08-09 15:45:51 +00:00
|
|
|
[ 'modifyField', 'slot_roles', 'role_id', 'patch-slot_roles-role_id-fix_not_null.sql' ],
|
|
|
|
|
[ 'modifyField', 'content_models', 'model_id', 'patch-content_models-model_id-fix_not_null.sql' ],
|
2020-11-28 11:16:20 +00:00
|
|
|
[ 'modifyField', 'categorylinks', 'cl_to', 'patch-categorylinks-cl_to-varbinary.sql' ],
|
2020-12-06 00:12:01 +00:00
|
|
|
[ 'modifyField', 'logging', 'log_title', 'patch-logging-log_title-varbinary.sql' ],
|
2020-12-14 16:37:53 +00:00
|
|
|
[ 'renameIndex', 'user_properties', 'user_properties_property', 'up_property', false,
|
|
|
|
|
'patch-user_properties-rename-index.sql' ],
|
2020-12-15 04:16:54 +00:00
|
|
|
[ 'renameIndex', 'sites', 'sites_global_key', 'site_global_key', false, 'patch-sites-rename-indexes.sql' ],
|
2020-12-13 01:52:49 +00:00
|
|
|
[ 'renameIndex', 'logging', 'type_time', 'log_type_time', false, 'patch-logging-rename-indexes.sql' ],
|
2020-12-20 21:42:14 +00:00
|
|
|
[ 'modifyField', 'filearchive', 'fa_name', 'patch-filearchive-fa_name.sql' ],
|
2021-01-16 19:42:23 +00:00
|
|
|
[ 'modifyField', 'oldimage', 'oi_name', 'patch-oldimage-oi_name-varbinary.sql' ],
|
2020-10-23 13:11:39 +00:00
|
|
|
[ 'modifyField', 'objectcache', 'exptime', 'patch-objectcache-exptime-notnull.sql' ],
|
2021-01-23 05:02:25 +00:00
|
|
|
[ 'modifyField', 'ipblocks', 'ipb_timestamp', 'patch-ipblocks-ipb_timestamp-drop-default.sql' ],
|
2021-01-23 09:00:00 +00:00
|
|
|
[ 'renameIndex', 'archive', 'name_title_timestamp', 'ar_name_title_timestamp', false,
|
|
|
|
|
'patch-archive-rename-name_title_timestamp-index.sql' ],
|
2021-01-28 19:13:03 +00:00
|
|
|
[ 'modifyField', 'image', 'img_name', 'patch-image-img_name-varbinary.sql' ],
|
2020-12-21 12:52:44 +00:00
|
|
|
[ 'renameIndex', 'site_identifiers', 'site_ids_key', 'si_key', false,
|
|
|
|
|
'patch-site_identifiers-rename-indexes.sql' ],
|
2021-02-26 12:52:22 +00:00
|
|
|
[ 'modifyField', 'recentchanges', 'rc_title', 'patch-recentchanges-rc_title-varbinary.sql' ],
|
2021-02-27 18:37:49 +00:00
|
|
|
[ 'renameIndex', 'recentchanges', 'new_name_timestamp', 'rc_new_name_timestamp', false,
|
|
|
|
|
'patch-recentchanges-rc_new_name_timestamp.sql' ],
|
2021-03-13 19:49:25 +00:00
|
|
|
[ 'modifyField', 'archive', 'ar_title', 'patch-archive-ar_title-varbinary.sql' ],
|
2020-11-23 04:33:36 +00:00
|
|
|
[ 'modifyField', 'page', 'page_title', 'patch-page-page_title-varbinary.sql' ],
|
2021-03-27 09:28:18 +00:00
|
|
|
[ 'modifyField', 'user', 'user_name', 'patch-user_table-updates.sql' ],
|
2020-11-23 04:33:36 +00:00
|
|
|
|
2021-03-22 14:42:19 +00:00
|
|
|
// 1.37
|
|
|
|
|
[ 'renameIndex', 'revision', 'page_timestamp', 'rev_page_timestamp', false,
|
|
|
|
|
'patch-revision-rename-index.sql' ],
|
2021-02-24 15:44:24 +00:00
|
|
|
[ 'addField', 'objectcache', 'modtoken', 'patch-objectcache-modtoken.sql' ],
|
2021-03-21 15:32:35 +00:00
|
|
|
[ 'modifyField', 'revision', 'rev_timestamp', 'patch-revision-rev_timestamp-drop-default.sql' ],
|
2021-04-24 10:42:10 +00:00
|
|
|
[ 'addIndex', 'oldimage', 'oi_timestamp', 'patch-oldimage-oi_timestamp.sql' ],
|
2021-03-24 18:23:09 +00:00
|
|
|
[ 'renameIndex', 'page', 'name_title', 'page_name_title', false,
|
|
|
|
|
'patch-page-rename-name_title-index.sql' ],
|
2020-12-21 04:09:08 +00:00
|
|
|
[ 'renameIndex', 'change_tag', 'change_tag_rc_tag_id', 'ct_rc_tag_id', false,
|
|
|
|
|
'patch-change_tag-rename-indexes.sql' ],
|
2021-11-21 08:50:59 +00:00
|
|
|
|
|
|
|
|
// 1.38
|
|
|
|
|
[ 'doConvertDjvuMetadata' ],
|
2021-04-24 10:22:27 +00:00
|
|
|
[ 'dropField', 'page_restrictions', 'pr_user', 'patch-drop-page_restrictions-pr_user.sql' ],
|
2022-01-18 16:41:37 +00:00
|
|
|
[ 'addTable', 'linktarget', 'patch-linktarget.sql' ],
|
2022-01-27 08:43:27 +00:00
|
|
|
[ 'dropIndex', 'revision', 'rev_page_id', 'patch-drop-rev_page_id.sql' ],
|
2021-11-30 23:08:07 +00:00
|
|
|
[ 'modifyField', 'page_restrictions', 'pr_page', 'patch-page_restrictions-pr_page.sql' ],
|
|
|
|
|
[ 'modifyField', 'page_props', 'pp_page', 'patch-page_props-pp_page.sql' ],
|
|
|
|
|
[ 'modifyField', 'ipblocks_restrictions', 'ir_value', 'patch-ipblocks_restrictions-ir_value.sql' ],
|
2022-01-27 09:09:58 +00:00
|
|
|
[ 'addField', 'templatelinks', 'tl_target_id', 'patch-templatelinks-target_id.sql' ],
|
2022-02-28 03:05:58 +00:00
|
|
|
|
|
|
|
|
// 1.39
|
|
|
|
|
[ 'addTable', 'user_autocreate_serial', 'patch-user_autocreate_serial.sql' ],
|
2021-11-30 20:55:26 +00:00
|
|
|
[ 'modifyField', 'ipblocks_restrictions', 'ir_ipb_id', 'patch-ipblocks_restrictions-ir_ipb_id.sql' ],
|
|
|
|
|
[ 'modifyField', 'ipblocks', 'ipb_id', 'patch-ipblocks-ipb_id.sql' ],
|
2022-04-21 09:16:03 +00:00
|
|
|
[ 'modifyField', 'user', 'user_editcount', 'patch-user-user_editcount.sql' ],
|
2022-05-20 16:25:36 +00:00
|
|
|
[ 'runMaintenance', MigrateRevisionActorTemp::class, 'maintenance/migrateRevisionActorTemp.php' ],
|
|
|
|
|
[ 'dropTable', 'revision_actor_temp' ],
|
2022-05-24 08:51:57 +00:00
|
|
|
[ 'runMaintenance', UpdateRestrictions::class, 'maintenance/updateRestrictions.php' ],
|
|
|
|
|
[ 'dropField', 'page', 'page_restrictions', 'patch-page-drop-page_restrictions.sql' ],
|
2022-05-30 12:23:30 +00:00
|
|
|
[ 'migrateTemplatelinks' ],
|
|
|
|
|
[ 'modifyField', 'templatelinks', 'tl_namespace', 'patch-templatelinks-tl_title-nullable.sql' ],
|
2022-09-06 09:27:52 +00:00
|
|
|
[ 'dropField', 'templatelinks', 'tl_title', 'patch-templatelinks-drop-tl_title.sql' ],
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2010-07-20 22:28:50 +00:00
|
|
|
}
|
2010-09-11 09:49:57 +00:00
|
|
|
|
2020-05-04 20:16:03 +00:00
|
|
|
/**
|
|
|
|
|
* Check whether an index contain a field
|
|
|
|
|
*
|
|
|
|
|
* @param string $table Table name
|
|
|
|
|
* @param string $index Index name to check
|
|
|
|
|
* @param string $field Field that should be in the index
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
protected function indexHasField( $table, $index, $field ) {
|
|
|
|
|
$info = $this->db->indexInfo( $table, $index, __METHOD__ );
|
|
|
|
|
if ( $info ) {
|
|
|
|
|
foreach ( $info as $column ) {
|
|
|
|
|
if ( $column == $field ) {
|
|
|
|
|
$this->output( "...index $index on table $table includes field $field.\n" );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->output( "...index $index on table $table has no field $field; added.\n" );
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function doFixIpbAddressUniqueIndex() {
|
|
|
|
|
if ( !$this->indexHasField( 'ipblocks', 'ipb_address_unique', 'ipb_anon_only' ) ) {
|
|
|
|
|
$this->output( "...ipb_address_unique index up-to-date.\n" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->applyPatch(
|
|
|
|
|
'patch-ipblocks-fix-ipb_address_unique.sql',
|
|
|
|
|
false,
|
|
|
|
|
'Removing ipb_anon_only column from ipb_address_unique index'
|
|
|
|
|
);
|
|
|
|
|
}
|
2010-07-20 22:28:50 +00:00
|
|
|
}
|