3 * Sqlite-specific updater.
10 * Class for handling updates to Sqlite databases.
15 class SqliteUpdater
extends DatabaseUpdater
{
17 protected function getCoreUpdateList() {
20 array( 'addField', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ),
21 array( 'doActiveUsersInit' ),
22 array( 'addField', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ),
23 array( 'sqliteInitialIndexes' ),
26 array( 'addTable', 'change_tag', 'patch-change_tag.sql' ),
27 array( 'addTable', 'tag_summary', 'patch-change_tag.sql' ),
28 array( 'addTable', 'valid_tag', 'patch-change_tag.sql' ),
31 array( 'addTable', 'user_properties', 'patch-user_properties.sql' ),
32 array( 'addTable', 'log_search', 'patch-log_search.sql' ),
33 array( 'addField', 'logging', 'log_user_text', 'patch-log_user_text.sql' ),
34 array( 'doLogUsertextPopulation' ), # listed separately from the previous update because 1.16 was released without this update
35 array( 'doLogSearchPopulation' ),
36 array( 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ),
37 array( 'addTable', 'external_user', 'patch-external_user.sql' ),
38 array( 'addIndex', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ),
39 array( 'addIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ),
40 array( 'addField', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ),
41 array( 'doUpdateTranscacheField' ),
42 array( 'sqliteSetupSearchindex' ),
45 array( 'addTable', 'iwlinks', 'patch-iwlinks.sql' ),
46 array( 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
47 array( 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
48 array( 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
49 array( 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
50 array( 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
51 array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ),
52 array( 'doCollationUpdate' ),
53 array( 'addTable', 'msg_resource', 'patch-msg_resource.sql' ),
54 array( 'addTable', 'module_deps', 'patch-module_deps.sql' ),
55 array( 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ),
56 array( 'addIndex', 'archive', 'ar_revid', 'patch-archive_ar_revid.sql' ),
59 array( 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ),
60 array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
61 array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql'),
64 array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql'),
65 array( 'doMigrateUserOptions' ),
66 array( 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ),
67 array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ),
68 array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' ),
69 array( 'addIndex', 'page', 'page_redirect_namespace_len', 'patch-page_redirect_namespace_len.sql' ),
70 array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase.sql' ),
71 array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ),
72 array( 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ),
73 array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ug_group-length-increase.sql' ),
76 array( 'addTable', 'config', 'patch-config.sql' ),
77 array( 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ),
81 protected function sqliteInitialIndexes() {
82 // initial-indexes.sql fails if the indexes are already present, so we perform a quick check if our database is newer.
83 if ( $this->updateRowExists( 'initial_indexes' ) ||
$this->db
->indexExists( 'user', 'user_name', __METHOD__
) ) {
84 $this->output( "...have initial indexes\n" );
87 $this->output( "Adding initial indexes..." );
88 $this->applyPatch( 'initial-indexes.sql' );
89 $this->output( "done\n" );
92 protected function sqliteSetupSearchindex() {
93 $module = DatabaseSqlite
::getFulltextSearchModule();
94 $fts3tTable = $this->updateRowExists( 'fts3' );
95 if ( $fts3tTable && !$module ) {
96 $this->output( '...PHP is missing FTS3 support, downgrading tables...' );
97 $this->applyPatch( 'searchindex-no-fts.sql' );
98 $this->output( "done\n" );
99 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
100 $this->output( '...adding FTS3 search capabilities...' );
101 $this->applyPatch( 'searchindex-fts3.sql' );
102 $this->output( "done\n" );
104 $this->output( "...fulltext search table appears to be in order.\n" );