18ef7a4716c2aec86045641e8cd0d3f4c7dec2b8
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' ),
41 array( 'addTable', 'config', 'patch-config.sql' ),
42 array( 'addIndex', 'logging', 'i05', 'patch-logging_type_action_index.sql'),
43 array( 'addTable', 'globaltemplatelinks', 'patch-globaltemplatelinks.sql' ),
44 array( 'addTable', 'globalnamespaces', 'patch-globalnamespaces.sql' ),
45 array( 'addTable', 'globalinterwiki', 'patch-globalinterwiki.sql' ),
48 array( 'doRebuildDuplicateFunction' ),
54 * MySQL uses datatype defaults for NULL inserted into NOT NULL fields
55 * In namespace case that results into insert of 0 which is default namespace
56 * Oracle inserts NULL, so namespace fields should have a default value
58 protected function doNamespaceDefaults() {
59 $this->output( "Altering namespace fields with default value ... " );
60 $meta = $this->db
->fieldInfo( 'page', 'page_namespace' );
61 if ( $meta->defaultValue() != null ) {
62 $this->output( "defaults seem to present on namespace fields\n" );
66 $this->applyPatch( 'patch_namespace_defaults.sql', false );
67 $this->output( "ok\n" );
71 * Uniform FK names + deferrable state
73 protected function doFKRenameDeferr() {
74 $this->output( "Altering foreign keys ... " );
75 $meta = $this->db
->query( 'SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' );
76 $row = $meta->fetchRow();
77 if ( $row && $row['cnt'] > 0 ) {
78 $this->output( "at least one FK is deferrable, considering up to date\n" );
82 $this->applyPatch( 'patch_fk_rename_deferred.sql', false );
83 $this->output( "ok\n" );
87 * Recreate functions to 17 schema layout
89 protected function doFunctions17() {
90 $this->output( "Recreating functions ... " );
91 $this->applyPatch( 'patch_create_17_functions.sql', false );
92 $this->output( "ok\n" );
96 * Schema upgrade 16->17
97 * there are no incremental patches prior to this
99 protected function doSchemaUpgrade17() {
100 $this->output( "Updating schema to 17 ... " );
101 // check if iwlinks table exists which was added in 1.17
102 if ( $this->db
->tableExists( 'iwlinks' ) ) {
103 $this->output( "schema seem to be up to date.\n" );
106 $this->applyPatch( 'patch_16_17_schema_changes.sql', false );
107 $this->output( "ok\n" );
111 * Insert page (page_id = 0) to prevent FK constraint violation
113 protected function doInsertPage0() {
114 $this->output( "Inserting page 0 if missing ... " );
117 'page_namespace' => 0,
120 'page_is_redirect' => 0,
123 'page_touched' => $this->db
->timestamp(),
127 $this->db
->insert( 'page', $row, 'OracleUpdater:doInserPage0', array( 'IGNORE' ) );
128 $this->output( "ok\n" );
132 * Remove DEFAULT '' NOT NULL constraints from fields as '' is internally
133 * converted to NULL in Oracle
135 protected function doRemoveNotNullEmptyDefaults() {
136 $this->output( "Removing not null empty constraints ... " );
137 $meta = $this->db
->fieldInfo( 'categorylinks' , 'cl_sortkey_prefix' );
138 if ( $meta->isNullable() ) {
139 $this->output( "constraints seem to be removed\n" );
142 $this->applyPatch( 'patch_remove_not_null_empty_defs.sql', false );
143 $this->output( "ok\n" );
147 * rebuilding of the function that duplicates tables for tests
149 protected function doRebuildDuplicateFunction() {
150 $this->output( "Rebuilding duplicate function ... " );
151 $this->applyPatch( 'patch_rebuild_dupfunc.sql', false );
152 $this->output( "ok\n" );
156 * Overload: after this action field info table has to be rebuilt
160 public function doUpdates( $what = array( 'core', 'extensions', 'purge' ) ) {
161 parent
::doUpdates( $what );
163 $this->db
->query( 'BEGIN fill_wiki_info; END;' );