MDL-62325 enrol_paypal: Added some keys and indexes to enrol_paypal.

- Added these keys to the enrol_paypal db: courseid, userid, instanceid
- Added these indexes to the enrol_paypal db: business, receiver_email
This commit is contained in:
Shamim Rezaie
2018-06-25 13:01:16 +10:00
parent 7b1139543c
commit 7bb4d2d88e
3 changed files with 72 additions and 2 deletions
+8 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="enrol/paypal/db" VERSION="20120122" COMMENT="XMLDB file for Moodle enrol/paypal"
<XMLDB PATH="enrol/paypal/db" VERSION="20180625" COMMENT="XMLDB file for Moodle enrol/paypal"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
@@ -30,7 +30,14 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="courseid" TYPE="foreign" FIELDS="courseid" REFTABLE="course" REFFIELDS="id"/>
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
<KEY NAME="instanceid" TYPE="foreign" FIELDS="instanceid" REFTABLE="enrol" REFFIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="business" UNIQUE="false" FIELDS="business"/>
<INDEX NAME="receiver_email" UNIQUE="false" FIELDS="receiver_email"/>
</INDEXES>
</TABLE>
</TABLES>
</XMLDB>
+63
View File
@@ -75,5 +75,68 @@ function xmldb_enrol_paypal_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2017111301, 'enrol', 'paypal');
}
if ($oldversion < 2017111302) {
// Define key courseid (foreign) to be added to enrol_paypal.
$table = new xmldb_table('enrol_paypal');
$key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id'));
// Launch add key courseid.
$dbman->add_key($table, $key);
// Paypal savepoint reached.
upgrade_plugin_savepoint(true, 2017111302, 'enrol', 'paypal');
}
if ($oldversion < 2017111303) {
// Define key userid (foreign) to be added to enrol_paypal.
$table = new xmldb_table('enrol_paypal');
$key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
// Launch add key userid.
$dbman->add_key($table, $key);
// Paypal savepoint reached.
upgrade_plugin_savepoint(true, 2017111303, 'enrol', 'paypal');
}
if ($oldversion < 2017111304) {
// Define key instanceid (foreign) to be added to enrol_paypal.
$table = new xmldb_table('enrol_paypal');
$key = new xmldb_key('instanceid', XMLDB_KEY_FOREIGN, array('instanceid'), 'enrol', array('id'));
// Launch add key instanceid.
$dbman->add_key($table, $key);
// Paypal savepoint reached.
upgrade_plugin_savepoint(true, 2017111304, 'enrol', 'paypal');
}
if ($oldversion < 2017111305) {
$table = new xmldb_table('enrol_paypal');
// Define index business (not unique) to be added to enrol_paypal.
$index = new xmldb_index('business', XMLDB_INDEX_NOTUNIQUE, array('business'));
// Conditionally launch add index business.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Define index receiver_email (not unique) to be added to enrol_paypal.
$index = new xmldb_index('receiver_email', XMLDB_INDEX_NOTUNIQUE, array('receiver_email'));
// Conditionally launch add index receiver_email.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Paypal savepoint reached.
upgrade_plugin_savepoint(true, 2017111305, 'enrol', 'paypal');
}
return true;
}
+1 -1
View File
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2017111301; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2017111305; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2017110800; // Requires this Moodle version
$plugin->component = 'enrol_paypal'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 60;