Select Git revision
upgrade.php
-
Tobias Reischmann authoredTobias Reischmann authored
upgrade.php 11.84 KiB
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Update script for lifecycle plugin
*
* @package tool_lifecycle
* @copyright 2017 Tobias Reischmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
function xmldb_tool_lifecycle_upgrade($oldversion) {
global $DB;
$dbman = $DB->get_manager();
if ($oldversion < 2017081101) {
// Create table tool_lifecycle_workflow.
$table = new xmldb_table('tool_lifecycle_workflow');
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
$table->add_field('title', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'id');
$table->add_field('active', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'title');
$table->add_field('timeactive', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'active');
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
// Conditionally create the table.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Changing structure of table tool_lifecycle_step.
$table = new xmldb_table('tool_lifecycle_step');
$field = new xmldb_field('followedby');
// Conditionally drop followedby field.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
$field = new xmldb_field('workflowid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'subpluginname');
$key = new xmldb_key('workflowid_fk', XMLDB_KEY_FOREIGN, array('workflowid'), 'tool_lifecycle_workflow', array('id'));
// Conditionally create the field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
$dbman->add_key($table, $key);
}
$field = new xmldb_field('sortindex', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, null, 'workflowid');
// Conditionally create the field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}