modify_database('','ALTER TABLE prefix_glossary_ratings ADD INDEX entryid (entryid);');
}
+
+ //Delete orphaned categories (bug 2140)
+ if ($oldversion < 2005011100) {
+ $categories = get_records('glossary_categories', '', '', '', 'id, glossaryid');
+ if ($categories) {
+ foreach ($categories as $category) {
+ $glossary = get_record('glossary', 'id', "$category->glossaryid");
+ if (!$glossary) {
+ delete_records('glossary_categories', 'id', "$category->id");
+ }
+ }
+ }
+ }
return true;
}
modify_database('','CREATE INDEX prefix_glossary_ratings_entryid_idx ON prefix_glossary_ratings (entryid);');
}
+ //Delete orphaned categories (bug 2140)
+ if ($oldversion < 2005011100) {
+ $categories = get_records('glossary_categories', '', '', '', 'id, glossaryid');
+ if ($categories) {
+ foreach ($categories as $category) {
+ $glossary = get_record('glossary', 'id', "$category->glossaryid");
+ if (!$glossary) {
+ delete_records('glossary_categories', 'id', "$category->id");
+ }
+ }
+ }
+ }
+
return true;
}
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2004111200;
+$module->version = 2005011100;
$module->requires = 2004112300; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)