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( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql'),
47 array( 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
48 array( 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
49 array( 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
50 array( 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
51 array( 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
52 array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ),
53 array( 'doCollationUpdate' ),
54 array( 'addTable', 'msg_resource', 'patch-msg_resource.sql' ),
55 array( 'addTable', 'module_deps', 'patch-module_deps.sql' ),
56 array( 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ),
57 array( 'addIndex', 'archive', 'ar_revid', 'patch-archive_ar_revid.sql' ),
60 array( 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ),
61 array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
64 array( 'addTable', 'config', 'patch-config.sql' ),
65 array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql'),
66 array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ),
67 array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' )
71 protected function sqliteInitialIndexes() {
72 // initial-indexes.sql fails if the indexes are already present, so we perform a quick check if our database is newer.
73 if ( $this->updateRowExists( 'initial_indexes' ) ||
$this->db
->indexExists( 'user', 'user_name' ) ) {
74 $this->output( "...have initial indexes\n" );
77 $this->output( "Adding initial indexes..." );
78 $this->applyPatch( 'initial-indexes.sql' );
79 $this->output( "done\n" );
82 protected function sqliteSetupSearchindex() {
83 $module = DatabaseSqlite
::getFulltextSearchModule();
84 $fts3tTable = $this->updateRowExists( 'fts3' );
85 if ( $fts3tTable && !$module ) {
86 $this->output( '...PHP is missing FTS3 support, downgrading tables...' );
87 $this->applyPatch( 'searchindex-no-fts.sql' );
88 $this->output( "done\n" );
89 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
90 $this->output( '...adding FTS3 search capabilities...' );
91 $this->applyPatch( 'searchindex-fts3.sql' );
92 $this->output( "done\n" );
94 $this->output( "...fulltext search table appears to be in order.\n" );