diff --git a/db/upgrade.php b/db/upgrade.php new file mode 100644 index 0000000000000000000000000000000000000000..8082dde890b8ae1c1c54a24a7774d6f8218b1a23 --- /dev/null +++ b/db/upgrade.php @@ -0,0 +1,40 @@ +<?php + + + +function xmldb_block_career_upgrade($oldversion) { + global $DB; + + $dbman = $DB->get_manager(); + + if ($oldversion < 2021070101) { + + // Define table block_career_groups to be created. + $table = new xmldb_table('block_career_groups'); + + // Adding fields to table block_career_groups. + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('group_id', XMLDB_TYPE_INTEGER, '8', null, XMLDB_NOTNULL, null, '0'); + $table->add_field('career', XMLDB_TYPE_INTEGER, '8', null, XMLDB_NOTNULL, null, '0'); + $table->add_field('timeadded', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); + + // Adding keys to table block_career_groups. + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); + $table->add_key('career', XMLDB_KEY_FOREIGN, ['career'], 'block_career', ['id']); + $table->add_key('group_id', XMLDB_KEY_FOREIGN, ['group_id'], 'groups', ['id']); + + // Conditionally launch create table for block_career_groups. + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + // Career savepoint reached. + upgrade_block_savepoint(true, 2021070101, 'career'); + } + + + return true; +} + +?> + diff --git a/version.php b/version.php index b7bde4d58ec291225cc2e50e04090805f30a078c..5cd66360cf17d37bbd1925100cc682a34fad28b6 100644 --- a/version.php +++ b/version.php @@ -27,8 +27,9 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); - + $plugin->version = 2021070500; + $plugin->requires = 2014051200; $plugin->component = 'block_career'; $plugin->release = 'v1.1';