MDL-14797 - Error when moving a course to an empty category on Postgres
[moodle.git] / lib / db / upgrade.php
CommitLineData
4e423cbf 1<?PHP //$Id$
2
3// This file keeps track of upgrades to Moodle.
4//
5// Sometimes, changes between versions involve
6// alterations to database structures and other
7// major things that may break installations.
8//
9// The upgrade function in this file will attempt
10// to perform all the necessary actions to upgrade
11// your older installtion to the current version.
12//
13// If there's something it cannot do itself, it
14// will tell you what you need to do.
15//
16// The commands in here will all be database-neutral,
17// using the functions defined in lib/ddllib.php
18
19
20function xmldb_main_upgrade($oldversion=0) {
21
8a45fcdf 22 global $CFG, $THEME, $USER, $db;
4e423cbf 23
24 $result = true;
25
1ea260d8 26 ////////////////////////////////////////
27 ///upgrade supported only from 1.9.x ///
28 ////////////////////////////////////////
da4aa3e4 29
a1f27717 30 if ($result && $oldversion < 2008030700) {
31
32 /// Define index contextid-lowerboundary (not unique) to be dropped form grade_letters
33 $table = new XMLDBTable('grade_letters');
34 $index = new XMLDBIndex('contextid-lowerboundary');
35 $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
36
37 /// Launch drop index contextid-lowerboundary
38 $result = $result && drop_index($table, $index);
39
a1f27717 40 /// Define index contextid-lowerboundary-letter (unique) to be added to grade_letters
41 $table = new XMLDBTable('grade_letters');
42 $index = new XMLDBIndex('contextid-lowerboundary-letter');
43 $index->setAttributes(XMLDB_INDEX_UNIQUE, array('contextid', 'lowerboundary', 'letter'));
44
45 /// Launch add index contextid-lowerboundary-letter
46 $result = $result && add_index($table, $index);
47
48 /// Main savepoint reached
0f77b186 49 upgrade_main_savepoint($result, 2008030700);
50 }
a1f27717 51
1ea260d8 52 if ($result && $oldversion < 2008050100) {
53 // Update courses that used weekscss to weeks
54 $result = set_field('course', 'format', 'weeks', 'format', 'weekscss');
55 upgrade_main_savepoint($result, 2008050100);
56 }
57
0b51c247 58 if ($result && $oldversion < 2008050200) {
59 // remove unused config options
60 unset_config('statsrolesupgraded');
61 upgrade_main_savepoint($result, 2008050200);
62 }
63
994fbaab 64 if ($result && $oldversion < 2008050700) {
65 /// Fix minor problem caused by MDL-5482.
66 require_once($CFG->dirroot . '/question/upgrade.php');
67 $result = $result && question_fix_random_question_parents();
68 upgrade_main_savepoint($result, 2008050700);
69 }
70
ac9b0805 71 return $result;
4e423cbf 72}
271e6dec 73
74
4e423cbf 75?>