MDL-21146 fixed upgrade regression - we need to create all necessary "files" fields...
authorPetr Skoda <skodak@moodle.org>
Tue, 6 Apr 2010 18:45:02 +0000 (18:45 +0000)
committerPetr Skoda <skodak@moodle.org>
Tue, 6 Apr 2010 18:45:02 +0000 (18:45 +0000)
lib/db/install.xml
lib/db/upgrade.php

index 0122509..4e14ed1 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20100325" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20100406" COMMENT="XMLDB file for core Moodle tables"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
 >
         <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="Optional - general userid field - meaning depending on plugin" PREVIOUS="filename" NEXT="filesize"/>
         <FIELD NAME="filesize" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="userid" NEXT="mimetype"/>
         <FIELD NAME="mimetype" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false" COMMENT="type of file - jpeg image, open document spreadsheet" PREVIOUS="filesize" NEXT="status"/>
-        <FIELD NAME="status" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="number greater than 0 means something is wrong with this file (virus, missing, etc.)" PREVIOUS="mimetype" NEXT="timecreated"/>
-        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="status" NEXT="timemodified"/>
-        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="timecreated" NEXT="source"/>
-        <FIELD NAME="source" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="store the reference if the file is imported from external sites" PREVIOUS="timemodified" NEXT="author"/>
+        <FIELD NAME="status" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="number greater than 0 means something is wrong with this file (virus, missing, etc.)" PREVIOUS="mimetype" NEXT="source"/>
+        <FIELD NAME="source" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" COMMENT="contains the reference if the file is imported from external sites" PREVIOUS="status" NEXT="author"/>
         <FIELD NAME="author" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="The original author of the file" PREVIOUS="source" NEXT="license"/>
-        <FIELD NAME="license" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="license of the file to guide reuse" PREVIOUS="author"/>
+        <FIELD NAME="license" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="license of the file to guide reuse" PREVIOUS="author" NEXT="timecreated"/>
+        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="license" NEXT="timemodified"/>
+        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="timecreated"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="contextid"/>
       </KEYS>
     </TABLE>
   </TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index 913a6b7..ede4ed9 100644 (file)
@@ -474,6 +474,9 @@ function xmldb_main_upgrade($oldversion) {
         $table->add_field('filesize', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
         $table->add_field('mimetype', XMLDB_TYPE_CHAR, '100', null, null, null, null);
         $table->add_field('status', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+        $table->add_field('source', XMLDB_TYPE_TEXT, 'small', null, null, null, null);
+        $table->add_field('author', XMLDB_TYPE_CHAR, '255', null, null, null, null);
+        $table->add_field('license', XMLDB_TYPE_CHAR, '255', null, null, null, null);
         $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
         $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
 
@@ -3023,12 +3026,12 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
         upgrade_main_savepoint($result, 2010032400);
     }
 
-    if ($result && $oldversion < 2010033101) {
+    if ($result && $oldversion < 2010033101.01) {
 
     /// Define field source to be added to files
         $table = new xmldb_table('files');
 
-        $field = new xmldb_field('source', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'timemodified');
+        $field = new xmldb_field('source', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'status');
 
     /// Conditionally launch add field source
         if (!$dbman->field_exists($table, $field)) {
@@ -3049,6 +3052,11 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
             $dbman->add_field($table, $field);
         }
 
+        upgrade_main_savepoint($result, 2010033101.01);
+    }
+
+    if ($result && $oldversion < 2010033101.02) {
+        
     /// Define table license to be created
         $table = new xmldb_table('license');
 
@@ -3239,7 +3247,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
         set_config('sitedefaultlicense', 'allrightsreserved');
 
     /// Main savepoint reached
-        upgrade_main_savepoint($result, 2010033101);
+        upgrade_main_savepoint($result, 2010033101.02);
     }
 
     if ($result && $oldversion < 2010033102.00) {
@@ -3430,7 +3438,8 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
     return $result;
 }
 
-//TODO: Before 2.0 release
+//TODO: Cleanup before the 2.0 release - we do not want to drag along these dev machine fixes forever
 // 1/ remove the automatic enabling of completion lib if debug enabled ( in 2008121701 block)
 // 2/ move 2009061300 block to the top of the file so that we may log upgrade queries
-// 3/ force admin password change if salt not set, to be done after planned role changes
+// 3/ remove 2010033101 block
+// 4/ remove 2010032400 block
\ No newline at end of file