Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / mod / data / db / upgrade.php
blob232c38be42026ffea50d434a9edb4a5303982781
1 <?php //$Id$
3 // This file keeps track of upgrades to
4 // the data 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_data_upgrade($oldversion=0) {
22 global $CFG, $THEME, $db;
24 $result = true;
26 /// And upgrade begins here. For each one, you'll need one
27 /// block of code similar to the next one. Please, delete
28 /// this comment lines once this file start handling proper
29 /// upgrade code.
31 /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
32 /// $result = result of "/lib/ddllib.php" function calls
33 /// }
35 if ($result && $oldversion < 2006121300) {
37 /// Define field format to be added to data_comments
38 $table = new XMLDBTable('data_comments');
39 $field = new XMLDBField('format');
40 $field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'content');
42 /// Launch add field format
43 $result = $result && add_field($table, $field);
47 if ($result && $oldversion < 2007022600) {
48 /// Define field asearchtemplate to be added to data
49 $table = new XMLDBTable('data');
50 $field = new XMLDBField('asearchtemplate');
51 $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
53 /// Launch add field asearchtemplate
54 $result = $result && add_field($table, $field);
58 if ($result && $oldversion < 2007072200) {
59 require_once($CFG->dirroot.'/mod/data/lib.php');
60 // too much debug output
61 $db->debug = false;
62 data_update_grades();
63 $db->debug = true;
66 if ($result && $oldversion < 2007081400) {
68 /// Define field notification to be added to data
69 $table = new XMLDBTable('data');
70 $field = new XMLDBField('notification');
71 $field->setAttributes(XMLDB_TYPE_INTEGER, '10', null, null, null, null, null, null, 'editany');
73 /// Launch add field notification
74 $result = $result && add_field($table, $field);
77 if ($result && $oldversion < 2007081402) {
79 /// Define index type-dataid (not unique) to be added to data_fields
80 $table = new XMLDBTable('data_fields');
81 $index = new XMLDBIndex('type-dataid');
82 $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('type', 'dataid'));
84 /// Launch add index type-dataid
85 if (!index_exists($table, $index)) {
86 $result = $result && add_index($table, $index);
89 /// Define index course (not unique) to be added to data
90 $table = new XMLDBTable('data');
91 $index = new XMLDBIndex('course');
92 $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('course'));
94 /// Launch add index course
95 if (!index_exists($table, $index)) {
96 $result = $result && add_index($table, $index);
100 //===== 1.9.0 upgrade line ======//
102 if ($result && $oldversion < 2007101512) {
103 /// Launch add field asearchtemplate again if does not exists yet - reported on several sites
105 $table = new XMLDBTable('data');
106 $field = new XMLDBField('asearchtemplate');
107 $field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'jstemplate');
109 if (!field_exists($table, $field)) {
110 $result = $result && add_field($table, $field);
114 return $result;