upgrade.php 2.79 KB
Newer Older
1
<?php
2
// This file keeps track of upgrades to
3
4
5
6
7
8
9
10
// the data module
//
// Sometimes, changes between versions involve
// alterations to database structures and other
// major things that may break installations.
//
// The upgrade function in this file will attempt
// to perform all the necessary actions to upgrade
Petr Skoda's avatar
Petr Skoda committed
11
// your older installation to the current version.
12
13
14
15
16
//
// If there's something it cannot do itself, it
// will tell you what you need to do.
//
// The commands in here will all be database-neutral,
17
// using the methods of database_manager class
18
19
20
//
// Please do not forget to use upgrade_set_timeout()
// before any action that may take longer time to finish.
21

22
23
defined('MOODLE_INTERNAL') || die();

24
function xmldb_data_upgrade($oldversion) {
25
    global $CFG, $DB;
26

27
    $dbman = $DB->get_manager();
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
    if ($oldversion < 2016030300) {

        // Define field timemodified to be added to data.
        $table = new xmldb_table('data');
        $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'notification');

        // Conditionally launch add field timemodified.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }

        // Data savepoint reached.
        upgrade_mod_savepoint(true, 2016030300, 'data');
    }


45
46
47
    // Moodle v3.1.0 release upgrade line.
    // Put any upgrade step following this.

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    if ($oldversion < 2016090600) {

        // Define field config to be added to data.
        $table = new xmldb_table('data');
        $field = new xmldb_field('config', XMLDB_TYPE_TEXT, null, null, null, null, null, 'timemodified');

        // Conditionally launch add field config.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }

        // Data savepoint reached.
        upgrade_mod_savepoint(true, 2016090600, 'data');
    }

63
64
65
    // Automatically generated Moodle v3.2.0 release upgrade line.
    // Put any upgrade step following this.

66
67
68
69
    if ($oldversion < 2017032800) {

        // Define field completionentries to be added to data. Require a number of entries to be considered complete.
        $table = new xmldb_table('data');
70
        $field = new xmldb_field('completionentries', XMLDB_TYPE_INTEGER, '10', null, null, null, '0', 'config');
71
72
73
74
75
76
77
78
79
80

        // Conditionally launch add field timemodified.
        if (!$dbman->field_exists($table, $field)) {
            $dbman->add_field($table, $field);
        }

        // Data savepoint reached.
        upgrade_mod_savepoint(true, 2017032800, 'data');
    }

81
82
83
    // Automatically generated Moodle v3.3.0 release upgrade line.
    // Put any upgrade step following this.

84
85
86
    // Automatically generated Moodle v3.4.0 release upgrade line.
    // Put any upgrade step following this.

87
    return true;
88
}