Skip to content

Commit

Permalink
Fixed DB issue present in issue 35 and 36
Browse files Browse the repository at this point in the history
  • Loading branch information
ADLMeganBohland committed Apr 25, 2024
1 parent b658786 commit c956e04
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,17 @@ function xmldb_cmi5launch_upgrade($oldversion) {
// Define index lmsid (not unique) to be added to cmi5launch_sessions.
$indexnew = new xmldb_index('sessionid', XMLDB_INDEX_NOTUNIQUE, ['sessionid']);

// Conditionally launch add index lmsid.
if (!$dbman->index_exists($table, $indexnew)) {
// If table exists
// Conditionally launch create table for cmi5launch.
if ($dbman->table_exists($table)) {

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

}

// Cmi5launch savepoint reached.
upgrade_mod_savepoint(true, 2024032112, 'cmi5launch');
}
Expand All @@ -84,10 +90,17 @@ function xmldb_cmi5launch_upgrade($oldversion) {
// Now cycle through array and remove fields.
foreach ($tablestoadd as $table) {

// Conditionally launch add field moodlecourseid.
if (!$dbman->field_exists($table, $fieldmcid)) {
$dbman->add_field($table, $fieldmcid);
}
// If the table exists
// Conditionally launch add index lmsid.
// Conditionally launch create table for cmi5launch.
if ($dbman->table_exists($table)) {

// Conditionally launch add field moodlecourseid.
if (!$dbman->field_exists($table, $fieldmcid)) {
$dbman->add_field($table, $fieldmcid);
}
}

}

// Cmi5launch savepoint reached.
Expand Down

0 comments on commit c956e04

Please sign in to comment.