MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / lesson / db / upgrade.php
blobf53fc1dac988d3bdfb62e7bcaf8cf317086c0bc9
1 <?php //$Id$
3 // This file keeps track of upgrades to
4 // the lesson module
5 //
6 // Sometimes, changes between versions involve
7 // alterations to database structures and other
8 // major things that may break installations.
9 //
10 // The upgrade function in this file will attempt
11 // to perform all the necessary actions to upgrade
12 // your older installtion to the current version.
14 // If there's something it cannot do itself, it
15 // will tell you what you need to do.
17 // The commands in here will all be database-neutral,
18 // using the functions defined in lib/ddllib.php
20 function xmldb_lesson_upgrade($oldversion=0) {
22 global $CFG, $THEME, $db;
24 $result = true;
26 if ($result && $oldversion < 2006091802) {
28 /// Changing nullability of field response on table lesson_answers to null
29 $table = new XMLDBTable('lesson_answers');
30 $field = new XMLDBField('response');
31 $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'answer');
33 /// Launch change of nullability for field response
34 $result = $result && change_field_notnull($table, $field);
37 if ($result && $oldversion < 2006091803) {
39 /// Changing nullability of field useranswer on table lesson_attempts to null
40 $table = new XMLDBTable('lesson_attempts');
41 $field = new XMLDBField('useranswer');
42 $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'correct');
44 /// Launch change of nullability for field useranswer
45 $result = $result && change_field_notnull($table, $field);
48 if ($result && $oldversion < 2007020201) {
50 /// Changing nullability of field answer on table lesson_answers to null
51 $table = new XMLDBTable('lesson_answers');
52 $field = new XMLDBField('answer');
53 $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'timemodified');
55 /// Launch change of nullability for field answer
56 $result = $result && change_field_notnull($table, $field);
59 if ($result && $oldversion < 2007072200) {
60 require_once($CFG->dirroot.'/mod/lesson/lib.php');
61 // too much debug output
62 $db->debug = false;
63 lesson_update_grades();
64 $db->debug = true;
67 return $result;