Merge branch 'MDL-25793' of git://github.com/samhemelryk/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 10 Jan 2011 23:33:56 +0000 (00:33 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 10 Jan 2011 23:33:56 +0000 (00:33 +0100)
1  2 
mod/wiki/db/upgrade.php

@@@ -322,22 -359,37 +352,53 @@@ function xmldb_wiki_upgrade($oldversion
  
          upgrade_mod_savepoint(true, 2010102800, 'wiki');
      }
 -    
 +
+     if ($oldversion < 2011011000) {
+         // Fix wiki in the post table after upgrade from 1.9
+         $table = new xmldb_table('wiki');
 -        
++
+         // name should default to Wiki
+         $field = new xmldb_field('name', XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL, null, 'Wiki', 'course');
+         if ($dbman->field_exists($table, $field)) {
+             $dbman->change_field_default($table, $field);
+         }
 -        
++
+         // timecreated field is missing after 1.9 upgrade
+         $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'introformat');
+         if (!$dbman->field_exists($table, $field)) {
+             $dbman->add_field($table, $field);
+         }
 -        
++
+         // timemodified field is missing after 1.9 upgrade
+         $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, 0, 'timecreated');
+         if (!$dbman->field_exists($table, $field)) {
+             $dbman->add_field($table, $field);
+         }
 -        
++
+         // scaleid is not there any more
+         $field = new xmldb_field('scaleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
+         if ($dbman->field_exists($table, $field)) {
+             $dbman->drop_field($table, $field);
+         }
 -        
++
+         upgrade_mod_savepoint(true, 2011011000, 'wiki');
+     }
 +    // TODO: Will hold the old tables so we will have chance to fix problems
 +    // Will remove old tables once migrating 100% stable
 +    // Step 10: delete old tables
 +    //if ($oldversion < 2011000000) {
 +        //$tables = array('wiki_pages', 'wiki_locks', 'wiki_entries');
 +
 +        //foreach ($tables as $tablename) {
 +            //$table = new xmldb_table($tablename . '_old');
 +            //if ($dbman->table_exists($table)) {
 +                //$dbman->drop_table($table);
 +            //}
 +        //}
 +        //echo $OUTPUT->notification('Droping old tables', 'notifysuccess');
 +        //upgrade_mod_savepoint(true, 2011000000, 'wiki');
 +    //}
 +
      return true;
  }