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

Integradted workflows in step and trigger table and removed followedby

parent 8fa6fd21
No related branches found
No related tags found
No related merge requests found
...@@ -44,10 +44,12 @@ ...@@ -44,10 +44,12 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/> <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 step"/> <FIELD NAME="instancename" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="instancename of the step"/>
<FIELD NAME="subpluginname" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="name of the subplugin"/> <FIELD NAME="subpluginname" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="name of the subplugin"/>
<FIELD NAME="followedby" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="tells which step follows this one in the cleanup process"/> <FIELD NAME="workflowid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="id of the workflow"/>
<FIELD NAME="sortindex" TYPE="int" LENGTH="5" NOTNULL="true" SEQUENCE="false" COMMENT="Order within the workflow in which the steps are executed"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/> <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="workflowid_fk" TYPE="foreign" FIELDS="workflowid" REFTABLE="tool_cleanupcourses_workflow" REFFIELDS="id"/>
</KEYS> </KEYS>
</TABLE> </TABLE>
<TABLE NAME="tool_cleanupcourses_settings" COMMENT="Settings for step instances"> <TABLE NAME="tool_cleanupcourses_settings" COMMENT="Settings for step instances">
...@@ -101,18 +103,5 @@ ...@@ -101,18 +103,5 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id"/> <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS> </KEYS>
</TABLE> </TABLE>
<TABLE NAME="tool_cleanupcourses_wf_steps" COMMENT="Assignment of steps to a workflow">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="workflowid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="id of the workflow"/>
<FIELD NAME="stepid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Id of the step instance"/>
<FIELD NAME="order" TYPE="int" LENGTH="5" NOTNULL="true" SEQUENCE="false" COMMENT="Order in which the steps are executed"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="workflowid_fk" TYPE="foreign" FIELDS="workflowid" REFTABLE="tool_cleanupcourses_workflow" REFFIELDS="id"/>
<KEY NAME="stepid_fk" TYPE="foreign" FIELDS="stepid" REFTABLE="tool_cleanupcourses_step" REFFIELDS="id"/>
</KEYS>
</TABLE>
</TABLES> </TABLES>
</XMLDB> </XMLDB>
\ No newline at end of file
...@@ -29,23 +29,7 @@ function xmldb_tool_cleanupcourses_upgrade($oldversion) { ...@@ -29,23 +29,7 @@ function xmldb_tool_cleanupcourses_upgrade($oldversion) {
global $DB; global $DB;
$dbman = $DB->get_manager(); $dbman = $DB->get_manager();
if ($oldversion < 2017081000) { if ($oldversion < 2017081100) {
// Create table tool_cleanupcourses_wf_steps.
$table = new xmldb_table('tool_cleanupcourses_wf_steps');
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
$table->add_field('workflowid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'id');
$table->add_field('stepid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null, 'workflowid');
$table->add_field('sortindex', XMLDB_TYPE_INTEGER, '5', null, XMLDB_NOTNULL, null, null, 'stepid');
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('workflowid_fk', XMLDB_KEY_FOREIGN, array('workflowid'), 'tool_cleanupcourses_workflow', array('id'));
$table->add_key('stepid_fk', XMLDB_KEY_FOREIGN, array('stepid'), 'tool_cleanupcourses_step', array('id'));
// Conditionally create the table.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Create table tool_cleanupcourses_workflow. // Create table tool_cleanupcourses_workflow.
$table = new xmldb_table('tool_cleanupcourses_workflow'); $table = new xmldb_table('tool_cleanupcourses_workflow');
...@@ -62,20 +46,50 @@ function xmldb_tool_cleanupcourses_upgrade($oldversion) { ...@@ -62,20 +46,50 @@ function xmldb_tool_cleanupcourses_upgrade($oldversion) {
// Changing precision of field followedby on table tool_cleanupcourses_step to (10). // Changing precision of field followedby on table tool_cleanupcourses_step to (10).
$table = new xmldb_table('tool_cleanupcourses_step'); $table = new xmldb_table('tool_cleanupcourses_step');
$field = new xmldb_field('followedby', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'subpluginname'); $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_cleanupcourses_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');
// Launch change of precision for field followedby. // Conditionally create the field.
$dbman->change_field_precision($table, $field); if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Changing precision of field followedby on table tool_cleanupcourses_trigger to (10). // Changing precision of field followedby on table tool_cleanupcourses_trigger to (10).
$table = new xmldb_table('tool_cleanupcourses_trigger'); $table = new xmldb_table('tool_cleanupcourses_trigger');
$field = new xmldb_field('followedby', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'enabled'); $field = new xmldb_field('followedby');
// Conditionally drop followedby field
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
// Launch change of precision for field followedby. // Add workflowfield to trigger
$dbman->change_field_precision($table, $field); $field = new xmldb_field('workflowid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'enabled');
$key = new xmldb_key('workflowid_fk', XMLDB_KEY_FOREIGN, array('workflowid'), 'tool_cleanupcourses_workflow', array('id'));
// Conditionally create the field.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
$dbman->add_key($table, $key);
}
// Cleanupcourses savepoint reached. // Cleanupcourses savepoint reached.
upgrade_plugin_savepoint(true, 2017081000, 'tool', 'cleanupcourses'); upgrade_plugin_savepoint(true, 2017081100, 'tool', 'cleanupcourses');
} }
return true; return true;
......
...@@ -23,5 +23,5 @@ ...@@ -23,5 +23,5 @@
defined('MOODLE_INTERNAL') || die; defined('MOODLE_INTERNAL') || die;
$plugin->version = 2017081000; $plugin->version = 2017081100;
$plugin->component = 'tool_cleanupcourses'; $plugin->component = 'tool_cleanupcourses';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment