3 * Microsoft SQL Server-specific installer.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
25 * Class for setting up the MediaWiki database using Microsoft SQL Server.
31 class MssqlUpdater
extends DatabaseUpdater
{
38 protected function getCoreUpdateList() {
41 [ 'addField', 'mwuser', 'user_password_expires', 'patch-user_password_expires.sql' ],
44 [ 'addField', 'page', 'page_lang', 'patch-page_page_lang.sql' ],
47 [ 'dropTable', 'hitcounter' ],
48 [ 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ],
49 [ 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ],
50 // scripts were updated in 1.27 due to SQL errors; retaining old updatekeys so that people
51 // updating from 1.23->1.25->1.27 do not execute these scripts twice even though the
52 // updatekeys no longer make sense as they are.
53 [ 'updateSchema', 'categorylinks', 'cl_type-category_types-ck',
54 'patch-categorylinks-constraints.sql' ],
55 [ 'updateSchema', 'filearchive', 'fa_major_mime-major_mime-ck',
56 'patch-filearchive-constraints.sql' ],
57 [ 'updateSchema', 'oldimage', 'oi_major_mime-major_mime-ck',
58 'patch-oldimage-constraints.sql' ],
59 [ 'updateSchema', 'image', 'img_major_mime-major_mime-ck', 'patch-image-constraints.sql' ],
60 [ 'updateSchema', 'uploadstash', 'us_media_type-media_type-ck',
61 'patch-uploadstash-constraints.sql' ],
63 [ 'modifyField', 'image', 'img_major_mime',
64 'patch-img_major_mime-chemical.sql' ],
65 [ 'modifyField', 'oldimage', 'oi_major_mime',
66 'patch-oi_major_mime-chemical.sql' ],
67 [ 'modifyField', 'filearchive', 'fa_major_mime',
68 'patch-fa_major_mime-chemical.sql' ],
71 [ 'dropTable', 'msg_resource_links' ],
72 [ 'dropTable', 'msg_resource' ],
73 [ 'addField', 'watchlist', 'wl_id', 'patch-watchlist-wl_id.sql' ],
74 [ 'dropField', 'mwuser', 'user_options', 'patch-drop-user_options.sql' ],
75 [ 'addTable', 'bot_passwords', 'patch-bot_passwords.sql' ],
76 [ 'addField', 'pagelinks', 'pl_from_namespace', 'patch-pl_from_namespace.sql' ],
77 [ 'addField', 'templatelinks', 'tl_from_namespace', 'patch-tl_from_namespace.sql' ],
78 [ 'addField', 'imagelinks', 'il_from_namespace', 'patch-il_from_namespace.sql' ],
79 [ 'dropIndex', 'categorylinks', 'cl_collation', 'patch-kill-cl_collation_index.sql' ],
80 [ 'addIndex', 'categorylinks', 'cl_collation_ext',
81 'patch-add-cl_collation_ext_index.sql' ],
82 [ 'dropField', 'recentchanges', 'rc_cur_time', 'patch-drop-rc_cur_time.sql' ],
83 [ 'addField', 'page_props', 'pp_sortkey', 'patch-pp_sortkey.sql' ],
84 [ 'updateSchema', 'oldimage', 'oldimage varchar', 'patch-oldimage-schema.sql' ],
85 [ 'updateSchema', 'filearchive', 'filearchive varchar', 'patch-filearchive-schema.sql' ],
86 [ 'updateSchema', 'image', 'image varchar', 'patch-image-schema.sql' ],
87 [ 'updateSchema', 'recentchanges', 'recentchanges-drop-fks',
88 'patch-recentchanges-drop-fks.sql' ],
89 [ 'updateSchema', 'logging', 'logging-drop-fks', 'patch-logging-drop-fks.sql' ],
90 [ 'updateSchema', 'archive', 'archive-drop-fks', 'patch-archive-drop-fks.sql' ]
94 protected function applyPatch( $path, $isFullPath = false, $msg = null ) {
95 $prevScroll = $this->db
->scrollableCursor( false );
96 $prevPrep = $this->db
->prepareStatements( false );
97 parent
::applyPatch( $path, $isFullPath, $msg );
98 $this->db
->scrollableCursor( $prevScroll );
99 $this->db
->prepareStatements( $prevPrep );
103 * General schema update for a table that touches more than one field or requires
104 * destructive actions (such as dropping and recreating the table).
106 * @param string $table
107 * @param string $updatekey
108 * @param string $patch
109 * @param bool $fullpath
111 protected function updateSchema( $table, $updatekey, $patch, $fullpath = false ) {
112 if ( !$this->db
->tableExists( $table, __METHOD__
) ) {
113 $this->output( "...$table table does not exist, skipping schema update patch.\n" );
114 } elseif ( $this->updateRowExists( $updatekey ) ) {
115 $this->output( "...$table already had schema updated by $patch.\n" );
117 $this->insertUpdateRow( $updatekey );
119 return $this->applyPatch( $patch, $fullpath, "Updating schema of table $table" );