Merge branch 'MDL-59084-master' of git://github.com/andrewnicols/moodle
[moodle.git] / lib / db / upgrade.php
index 1dc0391..df03600 100644 (file)
@@ -2475,5 +2475,24 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint(true, 2017091200.00);
     }
 
+    if ($oldversion < 2017091201.00) {
+        // Define field userid to be added to task_adhoc.
+        $table = new xmldb_table('task_adhoc');
+        $field = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'customdata');
+
+        // Conditionally launch add field userid.
+        if (!$dbman->field_exists($table, $field)) {
+            $dbman->add_field($table, $field);
+        }
+
+        $key = new xmldb_key('useriduser', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
+
+        // Launch add key userid_user.
+        $dbman->add_key($table, $key);
+
+        // Main savepoint reached.
+        upgrade_main_savepoint(true, 2017091201.00);
+    }
+
     return true;
 }