3 * Oracle-specific updater.
10 * Class for handling updates to Oracle databases.
15 class OracleUpdater
extends DatabaseUpdater
{
18 * Handle to the database subclass
24 protected function getCoreUpdateList() {
27 array( 'doNamespaceDefaults' ),
28 array( 'doFKRenameDeferr' ),
29 array( 'doFunctions17' ),
30 array( 'doSchemaUpgrade17' ),
31 array( 'doInsertPage0' ),
32 array( 'doRemoveNotNullEmptyDefaults' ),
33 array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ),
36 array( 'addIndex', 'user', 'i02', 'patch-user_email_index.sql' ),
37 array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ),
38 array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
39 array( 'doRebuildLocalisationCache' ),
42 array( 'addTable', 'config', 'patch-config.sql' ),
43 array( 'addIndex', 'logging', 'i05', 'patch-logging_type_action_index.sql'),
44 array( 'addTable', 'globaltemplatelinks', 'patch-globaltemplatelinks.sql' ),
45 array( 'addTable', 'globalnamespaces', 'patch-globalnamespaces.sql' ),
46 array( 'addTable', 'globalinterwiki', 'patch-globalinterwiki.sql' ),
47 array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1_field.sql' ),
48 array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1_field.sql' ),
49 array( 'doRemoveNotNullEmptyDefaults2' ),
52 array( 'doRebuildDuplicateFunction' ),
58 * MySQL uses datatype defaults for NULL inserted into NOT NULL fields
59 * In namespace case that results into insert of 0 which is default namespace
60 * Oracle inserts NULL, so namespace fields should have a default value
62 protected function doNamespaceDefaults() {
63 $this->output( "Altering namespace fields with default value ... " );
64 $meta = $this->db
->fieldInfo( 'page', 'page_namespace' );
65 if ( $meta->defaultValue() != null ) {
66 $this->output( "defaults seem to present on namespace fields\n" );
70 $this->applyPatch( 'patch_namespace_defaults.sql', false );
71 $this->output( "ok\n" );
75 * Uniform FK names + deferrable state
77 protected function doFKRenameDeferr() {
78 $this->output( "Altering foreign keys ... " );
79 $meta = $this->db
->query( 'SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' );
80 $row = $meta->fetchRow();
81 if ( $row && $row['cnt'] > 0 ) {
82 $this->output( "at least one FK is deferrable, considering up to date\n" );
86 $this->applyPatch( 'patch_fk_rename_deferred.sql', false );
87 $this->output( "ok\n" );
91 * Recreate functions to 17 schema layout
93 protected function doFunctions17() {
94 $this->output( "Recreating functions ... " );
95 $this->applyPatch( 'patch_create_17_functions.sql', false );
96 $this->output( "ok\n" );
100 * Schema upgrade 16->17
101 * there are no incremental patches prior to this
103 protected function doSchemaUpgrade17() {
104 $this->output( "Updating schema to 17 ... " );
105 // check if iwlinks table exists which was added in 1.17
106 if ( $this->db
->tableExists( 'iwlinks' ) ) {
107 $this->output( "schema seem to be up to date.\n" );
110 $this->applyPatch( 'patch_16_17_schema_changes.sql', false );
111 $this->output( "ok\n" );
115 * Insert page (page_id = 0) to prevent FK constraint violation
117 protected function doInsertPage0() {
118 $this->output( "Inserting page 0 if missing ... " );
121 'page_namespace' => 0,
124 'page_is_redirect' => 0,
127 'page_touched' => $this->db
->timestamp(),
131 $this->db
->insert( 'page', $row, 'OracleUpdater:doInserPage0', array( 'IGNORE' ) );
132 $this->output( "ok\n" );
136 * Remove DEFAULT '' NOT NULL constraints from fields as '' is internally
137 * converted to NULL in Oracle
139 protected function doRemoveNotNullEmptyDefaults() {
140 $this->output( "Removing not null empty constraints ... " );
141 $meta = $this->db
->fieldInfo( 'categorylinks' , 'cl_sortkey_prefix' );
142 if ( $meta->isNullable() ) {
143 $this->output( "constraints seem to be removed\n" );
146 $this->applyPatch( 'patch_remove_not_null_empty_defs.sql', false );
147 $this->output( "ok\n" );
149 protected function doRemoveNotNullEmptyDefaults2() {
150 $this->output( "Removing not null empty constraints ... " );
151 $meta = $this->db
->fieldInfo( 'ipblocks' , 'ipb_by_text' );
152 if ( $meta->isNullable() ) {
153 $this->output( "constraints seem to be removed\n" );
156 $this->applyPatch( 'patch_remove_not_null_empty_defs2.sql', false );
157 $this->output( "ok\n" );
161 * rebuilding of the function that duplicates tables for tests
163 protected function doRebuildDuplicateFunction() {
164 $this->output( "Rebuilding duplicate function ... " );
165 $this->applyPatch( 'patch_rebuild_dupfunc.sql', false );
166 $this->output( "ok\n" );
170 * Overload: after this action field info table has to be rebuilt
174 public function doUpdates( $what = array( 'core', 'extensions', 'purge', 'stats' ) ) {
175 parent
::doUpdates( $what );
177 $this->db
->query( 'BEGIN fill_wiki_info; END;' );