3 // This file keeps track of upgrades to
6 // Sometimes, changes between versions involve
7 // alterations to database structures and other
8 // major things that may break installations.
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_resource_upgrade($oldversion=0) {
22 global $CFG, $THEME, $db;
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
31 /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
32 /// $result = result of "/lib/ddllib.php" function calls
35 if ($result && $oldversion < 2007011700) {
36 //move format from options to reference field because it was colliding with course blocks setting
37 execute_sql("UPDATE {$CFG->prefix}resource SET reference=options WHERE type='text' AND reference='' AND options!='showblocks'");
41 if ($result && $oldversion < 2007012000) {
43 /// Changing nullability of field summary on table resource to null
44 $table = new XMLDBTable('resource');
45 $field = new XMLDBField('summary');
46 $field->setAttributes(XMLDB_TYPE_TEXT
, 'small', null, null, null, null, null, null, 'reference');
48 /// Launch change of nullability for field summary
49 $result = $result && change_field_notnull($table, $field);
52 if ($result && $oldversion < 2007012001) {
54 if ($CFG->dbfamily
== 'mysql') { // Only needed under mysql. The rest are long texts since ages
56 /// Changing precision of field alltext on table resource to (medium)
57 $table = new XMLDBTable('resource');
58 $field = new XMLDBField('alltext');
59 $field->setAttributes(XMLDB_TYPE_TEXT
, 'medium', null, XMLDB_NOTNULL
, null, null, null, null, 'summary');
61 /// Launch change of precision for field alltext
62 $result = $result && change_field_precision($table, $field);