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 installation 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 methods of database_manager class
20 // Please do not forget to use upgrade_set_timeout()
21 // before any action that may take longer time to finish.
23 function xmldb_survey_upgrade($oldversion) {
26 $dbman = $DB->get_manager();
28 //===== 1.9.0 upgrade line ======//
30 if ($oldversion < 2009042002) {
32 /// Define field introformat to be added to survey
33 $table = new xmldb_table('survey');
34 $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER
, '4', XMLDB_UNSIGNED
, XMLDB_NOTNULL
, null, '0', 'intro');
36 /// Conditionally launch add field introformat
37 if (!$dbman->field_exists($table, $field)) {
38 $dbman->add_field($table, $field);
41 // conditionally migrate to html format in intro
42 if ($CFG->texteditors
!== 'textarea') {
43 $rs = $DB->get_recordset('survey', array('introformat'=>FORMAT_MOODLE
), '', 'id,intro,introformat');
45 $s->intro
= text_to_html($s->intro
, false, false, true);
46 $s->introformat
= FORMAT_HTML
;
47 $DB->update_record('survey', $s);
48 upgrade_set_timeout();
53 /// survey savepoint reached
54 upgrade_mod_savepoint(true, 2009042002, 'survey');
57 // Moodle v2.1.0 release upgrade line
58 // Put any upgrade step following this