Commit 9d27b68c authored by Shamim Rezaie's avatar Shamim Rezaie
Browse files

MDL-59438 calendar: Added a foreign key and an index

Added foreign key constraint to the event.subscriptionid column.
Also added index to the event.uuid column.
parent 109aa076
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20171026" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20171205" COMMENT="XMLDB file for core Moodle tables"
......@@ -449,12 +449,14 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="categoryid" TYPE="foreign" FIELDS="categoryid" REFTABLE="course_categories" REFFIELDS="id"/>
<KEY NAME="subscriptionid" TYPE="foreign" FIELDS="subscriptionid" REFTABLE="event_subscriptions" REFFIELDS="id"/>
<INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid"/>
<INDEX NAME="userid" UNIQUE="false" FIELDS="userid"/>
<INDEX NAME="timestart" UNIQUE="false" FIELDS="timestart"/>
<INDEX NAME="timeduration" UNIQUE="false" FIELDS="timeduration"/>
<INDEX NAME="uuid" UNIQUE="false" FIELDS="uuid"/>
<INDEX NAME="type-timesort" UNIQUE="false" FIELDS="type, timesort"/>
<INDEX NAME="groupid-courseid-categoryid-visible-userid" UNIQUE="false" FIELDS="groupid, courseid, categoryid, visible, userid" COMMENT="used for calendar view"/>
......@@ -3760,4 +3762,4 @@
\ No newline at end of file
......@@ -1837,5 +1837,27 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2017111300.02);
if ($oldversion < 2017120100.01) {
// Define key subscriptionid (foreign) to be added to event.
$table = new xmldb_table('event');
$key = new xmldb_key('subscriptionid', XMLDB_KEY_FOREIGN, array('subscriptionid'), 'event_subscriptions', array('id'));
// Launch add key subscriptionid.
$dbman->add_key($table, $key);
// Define index uuid (not unique) to be added to event.
$table = new xmldb_table('event');
$index = new xmldb_index('uuid', XMLDB_INDEX_NOTUNIQUE, array('uuid'));
// Conditionally launch add index uuid.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
// Main savepoint reached.
upgrade_main_savepoint(true, 2017120100.01);
return true;
......@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2017120800.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2017120800.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment