a60c6686fe6ef855937ebe0f42e1b605f6484d25
[lhc/web/wiklou.git] / includes / installer / OracleUpdater.php
1 <?php
2 /**
3 * Oracle-specific updater.
4 *
5 * @file
6 * @ingroup Deployment
7 */
8
9 /**
10 * Class for handling updates to Oracle databases.
11 *
12 * @ingroup Deployment
13 * @since 1.17
14 */
15 class OracleUpdater extends DatabaseUpdater {
16
17 protected function __construct( DatabaseBase &$db, $shared ) {
18 define( 'MEDIAWIKI_INSTALL', true );
19 parent::__construct( $db, $shared );
20 }
21
22 protected function getCoreUpdateList() {
23 return array(
24 // 1.16
25 array( 'doNamespaceDefaults' ),
26 array( 'doFKRenameDeferr' ),
27 array( 'doFunctions17' ),
28 array( 'doSchemaUpgrade17' ),
29 );
30 }
31
32
33 /**
34 * MySQL uses datatype defaults for NULL inserted into NOT NULL fields
35 * In namespace case that results into insert of 0 which is default namespace
36 * Oracle inserts NULL, so namespace fields should have a default value
37 */
38 protected function doNamespaceDefaults() {
39 $this->output( "Altering namespace fields with default value ... " );
40 $meta = $this->db->fieldInfo( 'page', 'page_namespace' );
41 if ( $meta->defaultValue() != null ) {
42 $this->output( "defaults seem to present on namespace fields\n" );
43 return;
44 }
45
46 $this->applyPatch( 'patch_namespace_defaults.sql', false );
47 $this->output( "ok\n" );
48 }
49
50 /**
51 * Uniform FK names + deferrable state
52 */
53 protected function doFKRenameDeferr() {
54 $this->output( "Altering foreign keys ... " );
55 $meta = $this->db->query( 'SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' );
56 $row = $meta->fetchRow();
57 if ( $row && $row['cnt'] > 0 ) {
58 $this->output( "at least one FK is deferrable, considering up to date\n" );
59 return;
60 }
61
62 $this->applyPatch( 'patch_fk_rename_deferred.sql', false );
63 $this->output( "ok\n" );
64 }
65
66 /**
67 * Recreate functions to 17 schema layout
68 */
69 protected function doFunctions17() {
70 $this->output( "Recreating functions ... " );
71 $this->applyPatch( 'patch_create_17_functions.sql', false );
72 $this->output( "ok\n" );
73 }
74
75 /**
76 * Schema upgrade 16->17
77 * there are no incremental patches prior to this
78 */
79 protected function doSchemaUpgrade17() {
80 $this->output( "Updating schema to 17 ... " );
81 // check if iwlinks table exists which was added in 1.17
82 if ( $this->db->tableExists( trim( $this->db->tableName( 'iwlinks' ) ) ) ) {
83 $this->output( "schema seem to be up to date.\n" );
84 return;
85 }
86 $this->applyPatch( 'patch_16_17_schema_changes.sql', false );
87 $this->output( "ok\n" );
88 }
89
90 /**
91 * Overload: after this action field info table has to be rebuilt
92 */
93 public function doUpdates( $purge = true ) {
94 parent::doUpdates();
95
96 $this->db->query( 'BEGIN fill_wiki_info; END;' );
97 }
98
99 }