Skip to content
Snippets Groups Projects
Commit 3db474dc authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

Changed db trigger table to support trigger instances

parent 5feec36d
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="admin/tool/cleanupcourses/db" VERSION="2018021301" COMMENT="XMLDB file for Moodle tool/cleanupcourses"
<XMLDB PATH="admin/tool/cleanupcourses/db" VERSION="2018021302" COMMENT="XMLDB file for Moodle tool/cleanupcourses"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd">
<TABLES>
......@@ -32,13 +32,13 @@
<TABLE NAME="tool_cleanupcourses_trigger" COMMENT="Trigger subplugins for the cleanup courses">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="instancename" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="instancename of the trigger"/>
<FIELD NAME="subpluginname" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="name of the subplugin"/>
<FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="tells if the subplugin is enabled"/>
<FIELD NAME="followedby" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="tells which step follows this one in the cleanup process"/>
<FIELD NAME="sortindex" TYPE="int" LENGTH="3" NOTNULL="false" SEQUENCE="false" COMMENT="Sortindex of the subplugins"/>
<FIELD NAME="workflowid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="id of the workflow"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="workflowid_fk" TYPE="foreign" FIELDS="workflowid" REFTABLE="tool_cleanupcourses_workflow" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="tool_cleanupcourses_step" COMMENT="Step subplugins for the cleanup courses">
......
......@@ -150,6 +150,63 @@ function xmldb_tool_cleanupcourses_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2018021301, 'tool', 'cleanupcourses');
}
if ($oldversion < 2018021302) {
// Define field workflowid to be added to tool_cleanupcourses_trigger.
$table = new xmldb_table('tool_cleanupcourses_trigger');
$field = new xmldb_field('workflowid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'subpluginname');
// Conditionally launch add field workflowid.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field instancename to be added to tool_cleanupcourses_trigger.
$table = new xmldb_table('tool_cleanupcourses_trigger');
$field = new xmldb_field('instancename', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, 'workflowid');
// Conditionally launch add field instancename.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Define field enabled to be dropped from tool_cleanupcourses_trigger.
$table = new xmldb_table('tool_cleanupcourses_trigger');
$field = new xmldb_field('enabled');
// Conditionally launch drop field enabled.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// Define field sortindex to be dropped from tool_cleanupcourses_trigger.
$table = new xmldb_table('tool_cleanupcourses_trigger');
$field = new xmldb_field('sortindex');
// Conditionally launch drop field sortindex.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// Define field sortindex to be dropped from tool_cleanupcourses_trigger.
$table = new xmldb_table('tool_cleanupcourses_trigger');
$field = new xmldb_field('sortindex');
// Conditionally launch drop field sortindex.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// Define key workflowid_fk (foreign) to be added to tool_cleanupcourses_trigger.
$table = new xmldb_table('tool_cleanupcourses_trigger');
$key = new xmldb_key('workflowid_fk', XMLDB_KEY_FOREIGN, array('workflowid'), 'tool_cleanupcourses_workflow', array('id'));
// Launch add key workflowid_fk.
$dbman->add_key($table, $key);
// Cleanupcourses savepoint reached.
upgrade_plugin_savepoint(true, 2018021302, 'tool', 'cleanupcourses');
}
return true;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment