70 lines
3.4 KiB
PHP
70 lines
3.4 KiB
PHP
<?php
|
|
function xmldb_block_gradelevel_upgrade($oldversion) {
|
|
global $DB;
|
|
$dbman = $DB->get_manager();
|
|
|
|
/// Add a new column newcol to the mdl_myqtype_options
|
|
if ($oldversion < 2018091600) {
|
|
|
|
// Define table block_gradelevel_levelset to be created.
|
|
$table = new xmldb_table('block_gradelevel_levelset');
|
|
|
|
// Adding fields to table block_gradelevel_levelset.
|
|
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
|
$table->add_field('name', XMLDB_TYPE_CHAR, '128', null, null, null, null);
|
|
$table->add_field('parent_id', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
|
|
$table->add_field('icon', XMLDB_TYPE_TEXT, null, null, null, null, null);
|
|
|
|
|
|
// Adding keys to table block_gradelevel_levelset.
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
$table->add_key('parent_id_idx', XMLDB_KEY_FOREIGN, array('parent_id'), 'block_gradelevel_levelset', array('id'));
|
|
|
|
// Conditionally launch create table for block_gradelevel_levelset.
|
|
if (!$dbman->table_exists($table)) {
|
|
$dbman->create_table($table);
|
|
}
|
|
|
|
// Define table block_gradelevel_levels to be created.
|
|
$table = new xmldb_table('block_gradelevel_levels');
|
|
|
|
// Adding fields to table block_gradelevel_levels.
|
|
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
|
$table->add_field('levelset_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
|
$table->add_field('points', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
|
|
$table->add_field('badgecolor', XMLDB_TYPE_CHAR, '10', null, null, null, null);
|
|
|
|
// Adding keys to table block_gradelevel_levels.
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
$table->add_key('levelset_id_idx', XMLDB_KEY_FOREIGN, array('levelset_id'), 'block_gradelevel_levelset', array('id'));
|
|
|
|
// Conditionally launch create table for block_gradelevel_levels.
|
|
if (!$dbman->table_exists($table)) {
|
|
$dbman->create_table($table);
|
|
}
|
|
|
|
// Define table block_gradelevel_course_link to be created.
|
|
$table = new xmldb_table('block_gradelevel_course_link');
|
|
|
|
// Adding fields to table block_gradelevel_course_link.
|
|
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
|
$table->add_field('course_id', XMLDB_TYPE_INTEGER, '20', null, XMLDB_NOTNULL, null, null);
|
|
$table->add_field('levelset_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
|
|
|
// Adding keys to table block_gradelevel_course_link.
|
|
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
|
$table->add_key('course_id_idx', XMLDB_KEY_FOREIGN_UNIQUE, array('course_id'), 'mdl_course', array('id'));
|
|
$table->add_key('levelset_id_idx', XMLDB_KEY_FOREIGN, array('levelset_id'), 'block_gradelevel_levelset', array('id'));
|
|
|
|
// Conditionally launch create table for block_gradelevel_course_link.
|
|
if (!$dbman->table_exists($table)) {
|
|
$dbman->create_table($table);
|
|
}
|
|
|
|
// Gradelevel savepoint reached.
|
|
upgrade_block_savepoint(true, 2018091600, 'gradelevel');
|
|
|
|
}
|
|
|
|
return true;
|
|
} |