Refactored UploadStash and related classes to use the database for file metadata...
[lhc/web/wiklou.git] / includes / installer / SqliteUpdater.php
1 <?php
2 /**
3 * Sqlite-specific updater.
4 *
5 * @file
6 * @ingroup Deployment
7 */
8
9 /**
10 * Class for handling updates to Sqlite databases.
11 *
12 * @ingroup Deployment
13 * @since 1.17
14 */
15 class SqliteUpdater extends DatabaseUpdater {
16
17 protected function getCoreUpdateList() {
18 return array(
19 // 1.14
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' ),
24
25 // 1.15
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' ),
29
30 // 1.16
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' ),
43
44 // 1.17
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' ),
58
59 // 1.18
60 array( 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ),
61
62 // 1.19
63 array( 'addTable', 'config', 'patch-config.sql' ),
64 array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
65 );
66 }
67
68 protected function sqliteInitialIndexes() {
69 // initial-indexes.sql fails if the indexes are already present, so we perform a quick check if our database is newer.
70 if ( $this->updateRowExists( 'initial_indexes' ) || $this->db->indexExists( 'user', 'user_name' ) ) {
71 $this->output( "...have initial indexes\n" );
72 return;
73 }
74 $this->output( "Adding initial indexes..." );
75 $this->applyPatch( 'initial-indexes.sql' );
76 $this->output( "done\n" );
77 }
78
79 protected function sqliteSetupSearchindex() {
80 $module = DatabaseSqlite::getFulltextSearchModule();
81 $fts3tTable = $this->updateRowExists( 'fts3' );
82 if ( $fts3tTable && !$module ) {
83 $this->output( '...PHP is missing FTS3 support, downgrading tables...' );
84 $this->applyPatch( 'searchindex-no-fts.sql' );
85 $this->output( "done\n" );
86 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
87 $this->output( '...adding FTS3 search capabilities...' );
88 $this->applyPatch( 'searchindex-fts3.sql' );
89 $this->output( "done\n" );
90 } else {
91 $this->output( "...fulltext search table appears to be in order.\n" );
92 }
93 }
94 }