Skip to content

Commit

Permalink
Add index on customcert_issues table (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjnelson committed Jan 8, 2024
1 parent 1b36f91 commit 006bf10
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for customcert_issues"/>
<KEY NAME="customcert" TYPE="foreign" FIELDS="customcertid" REFTABLE="customcert" REFFIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="userid-customcertid" UNIQUE="true" FIELDS="userid, customcertid"/>
</INDEXES>
</TABLE>
<TABLE NAME="customcert_pages" COMMENT="Stores each page of a custom cert">
<FIELDS>
Expand Down
13 changes: 13 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,18 @@ function xmldb_customcert_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2022041903, 'customcert'); // Replace with the actual version number.
}

if ($oldversion < 2022041906) {
// Define index to be added to customcert_issues.
$table = new xmldb_table('customcert_issues');
$index = new xmldb_index('userid-customcertid', XMLDB_INDEX_UNIQUE, ['userid', 'customcertid']);

// Conditionally launch add index.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}

upgrade_mod_savepoint(true, 2022041906, 'customcert'); // Replace with the actual version number.
}

return true;
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');

$plugin->version = 2022041905; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2022041906; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2022041900; // Requires this Moodle version (4.0).
$plugin->cron = 0; // Period for cron to check this module (secs).
$plugin->component = 'mod_customcert';
Expand Down

0 comments on commit 006bf10

Please sign in to comment.