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-05-02 22:39:57 +10:00
parent 6153be6850
commit d6e821294e
3 changed files with 72 additions and 2 deletions

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>

View File

@ -75,5 +75,68 @@ function xmldb_enrol_paypal_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2018053000, 'enrol', 'paypal');
}
if ($oldversion < 2018062500) {
// 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, 2018062500, 'enrol', 'paypal');
}
if ($oldversion < 2018062501) {
// 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, 2018062501, 'enrol', 'paypal');
}
if ($oldversion < 2018062502) {
// 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, 2018062502, 'enrol', 'paypal');
}
if ($oldversion < 2018062503) {
$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, 2018062503, 'enrol', 'paypal');
}
return true;
}

View File

@ -25,6 +25,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2018053000; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2018062503; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2018050800; // Requires this Moodle version
$plugin->component = 'enrol_paypal'; // Full name of the plugin (used for diagnostics)