diff --git a/db/install.xml b/db/install.xml
index 1e2a789..f6ac796 100644
--- a/db/install.xml
+++ b/db/install.xml
@@ -23,7 +23,7 @@
-
+
diff --git a/db/upgrade.php b/db/upgrade.php
index 0b213ce..cab17db 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -146,5 +146,25 @@ function xmldb_customcert_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2018051705, 'customcert');
}
+ if ($oldversion < 2019111803) {
+ $table = new xmldb_table('customcert');
+ $index = new xmldb_index('templateid', XMLDB_INDEX_UNIQUE, ['templateid']);
+ if ($dbman->index_exists($table, $index)) {
+ $dbman->drop_index($table, $index);
+ }
+ $key = new xmldb_key('templateid', XMLDB_KEY_FOREIGN, array('templateid'), 'customcert_templates', array('id'));
+ $dbman->add_key($table, $key);
+
+ $table = new xmldb_table('customcert_pages');
+ $index = new xmldb_index('templateid', XMLDB_INDEX_UNIQUE, ['templateid']);
+ if ($dbman->index_exists($table, $index)) {
+ $dbman->drop_index($table, $index);
+ }
+ $key = new xmldb_key('templateid', XMLDB_KEY_FOREIGN, array('templateid'), 'customcert_templates', array('id'));
+ $dbman->add_key($table, $key);
+
+ upgrade_mod_savepoint(true, 2019111803, 'customcert');
+ }
+
return true;
}
diff --git a/version.php b/version.php
index c70f297..68aa109 100644
--- a/version.php
+++ b/version.php
@@ -24,10 +24,10 @@
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
-$plugin->version = 2019111802; // The current module version (Date: YYYYMMDDXX).
+$plugin->version = 2019111803; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2019111800; // Requires this Moodle version (3.8).
$plugin->cron = 0; // Period for cron to check this module (secs).
$plugin->component = 'mod_customcert';
$plugin->maturity = MATURITY_STABLE;
-$plugin->release = "3.8.2"; // User-friendly version number.
+$plugin->release = "3.8.3"; // User-friendly version number.