Skip to content
Snippets Groups Projects
Commit 5d4330b3 authored by TamaraGunkel's avatar TamaraGunkel
Browse files

Defined courseid as unique in process table

parent a05d46dc
Branches
Tags
No related merge requests found
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="admin/tool/cleanupcourses/db" VERSION="2018021302" COMMENT="XMLDB file for Moodle tool/cleanupcourses"
<XMLDB PATH="admin/tool/cleanupcourses/db" VERSION="2018022101" COMMENT="XMLDB file for Moodle tool/cleanupcourses"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd">
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="tool_cleanupcourses_process" COMMENT="table containing the state of all courses currently within the cleanup process">
<FIELDS>
......@@ -14,7 +15,7 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="courseid_fk" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" COMMENT="Foreign key on course table"/>
<KEY NAME="courseid_fk" TYPE="foreign-unique" FIELDS="courseid" REFTABLE="course" REFFIELDS="id" COMMENT="Foreign key on course table"/>
<KEY NAME="workflowid_fk" TYPE="foreign" FIELDS="workflowid" REFTABLE="tool_cleanupcourses_workflow" REFFIELDS="id"/>
</KEYS>
</TABLE>
......
......@@ -249,5 +249,24 @@ function xmldb_tool_cleanupcourses_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2018022005, 'tool', 'cleanupcourses');
}
if ($oldversion < 2018022101) {
// Define key courseid_fk (foreign) to be dropped form tool_cleanupcourses_process.
$table = new xmldb_table('tool_cleanupcourses_process');
$key = new xmldb_key('courseid_fk', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
// Launch drop key courseid_fk.
$dbman->drop_key($table, $key);
// Define key courseid_fk (foreign-unique) to be added to tool_cleanupcourses_process.
$key = new xmldb_key('courseid_fk', XMLDB_KEY_FOREIGN_UNIQUE, array('courseid'), 'course', array('id'));
// Launch add key courseid_fk.
$dbman->add_key($table, $key);
// Cleanupcourses savepoint reached.
upgrade_plugin_savepoint(true, 2018022101, 'tool', 'cleanupcourses');
}
return true;
}
\ No newline at end of file
......@@ -23,5 +23,5 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2018022011;
$plugin->version = 2018022101;
$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