MDL-28169 Installation Added 2.1 upgrade (idiot proof) lines to upgrade scripts.
[moodle.git] / mod / workshop / form / comments / db / upgrade.php
blob82402d7ab28de9ba3076b27707f8bf9d502933d2
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * Keeps track of upgrades to the workshop comments grading strategy
21 * @package workshopform
22 * @subpackage comments
23 * @copyright 2010 David Mudrak <david@moodle.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 /**
28 * Performs upgrade of the database structure and data
30 * @param int $oldversion the version we are upgrading from
31 * @return bool true
33 function xmldb_workshopform_comments_upgrade($oldversion) {
34 global $CFG, $DB, $OUTPUT;
36 $dbman = $DB->get_manager();
38 if ($oldversion < 2010091700) {
39 // clean up orphaned dimensions
40 $orphans = $DB->get_records_sql("SELECT d.id
41 FROM {workshopform_comments} d
42 LEFT JOIN {workshop} w ON d.workshopid = w.id
43 WHERE w.id IS NULL");
44 if (!empty($orphans)) {
45 echo $OUTPUT->notification('Orphaned assessment form elements found - cleaning...');
46 $DB->delete_records_list('workshopform_comments', 'id', array_keys($orphans));
49 upgrade_plugin_savepoint(true, 2010091700, 'workshopform', 'comments');
52 // Moodle v2.1.0 release upgrade line
53 // Put any upgrade step following this
55 return true;