diff --git a/admin/oacleanup.php b/admin/oacleanup.php
index 4c89b8b1804..2ae2c203016 100644
--- a/admin/oacleanup.php
+++ b/admin/oacleanup.php
@@ -29,7 +29,20 @@ function online_assignment_cleanup($output=false) {
echo '
';
}
- // get the module id for assignments from db
+
+ /// We don't want to run this code if we are doing an upgrade from an assignment
+ /// version earlier than 2005041400
+ /// because the assignment type field will not exist
+ $amv = get_field('modules', 'version', 'name', 'assignment');
+ if ((int)$amv < 2005041400) {
+ if ($output) {
+ echo '';
+ }
+ return;
+ }
+
+
+ /// get the module id for assignments from db
$arecord = get_record('modules', 'name', 'assignment');
$aid = $arecord->id;