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' ),
34 array( 'addIndex', 'user', 'i02', 'patch-user_email_index.sql' ),
35 array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ),
38 array( 'addTable', 'config', 'patch-config.sql' ),
44 * MySQL uses datatype defaults for NULL inserted into NOT NULL fields
45 * In namespace case that results into insert of 0 which is default namespace
46 * Oracle inserts NULL, so namespace fields should have a default value
48 protected function doNamespaceDefaults() {
49 $this->output( "Altering namespace fields with default value ... " );
50 $meta = $this->db
->fieldInfo( 'page', 'page_namespace' );
51 if ( $meta->defaultValue() != null ) {
52 $this->output( "defaults seem to present on namespace fields\n" );
56 $this->applyPatch( 'patch_namespace_defaults.sql', false );
57 $this->output( "ok\n" );
61 * Uniform FK names + deferrable state
63 protected function doFKRenameDeferr() {
64 $this->output( "Altering foreign keys ... " );
65 $meta = $this->db
->query( 'SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' );
66 $row = $meta->fetchRow();
67 if ( $row && $row['cnt'] > 0 ) {
68 $this->output( "at least one FK is deferrable, considering up to date\n" );
72 $this->applyPatch( 'patch_fk_rename_deferred.sql', false );
73 $this->output( "ok\n" );
77 * Recreate functions to 17 schema layout
79 protected function doFunctions17() {
80 $this->output( "Recreating functions ... " );
81 $this->applyPatch( 'patch_create_17_functions.sql', false );
82 $this->output( "ok\n" );
86 * Schema upgrade 16->17
87 * there are no incremental patches prior to this
89 protected function doSchemaUpgrade17() {
90 $this->output( "Updating schema to 17 ... " );
91 // check if iwlinks table exists which was added in 1.17
92 if ( $this->db
->tableExists( $this->db
->tableName( 'iwlinks' ) ) ) {
93 $this->output( "schema seem to be up to date.\n" );
96 $this->applyPatch( 'patch_16_17_schema_changes.sql', false );
97 $this->output( "ok\n" );
101 * Insert page (page_id = 0) to prevent FK constraint violation
103 protected function doInsertPage0() {
104 $this->output( "Inserting page 0 if missing ... " );
107 'page_namespace' => 0,
110 'page_is_redirect' => 0,
113 'page_touched' => $this->db
->timestamp(),
117 $this->db
->insert( 'page', $row, 'OracleUpdater:doInserPage0', array( 'IGNORE' ) );
118 $this->output( "ok\n" );
122 * Overload: after this action field info table has to be rebuilt
126 public function doUpdates( $what = array( 'core', 'extensions', 'purge' ) ) {
127 parent
::doUpdates( $what );
129 $this->db
->query( 'BEGIN fill_wiki_info; END;' );