From: skodak Date: Mon, 9 Jul 2007 13:58:17 +0000 (+0000) Subject: fixed loggeduser foreign keys X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=bc7afe29c3334736b1ce71a7a38fd551c03ca08b;p=moodle.git fixed loggeduser foreign keys --- diff --git a/lib/db/install.xml b/lib/db/install.xml index 673f2ca9c9..8459144f12 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -1393,7 +1393,8 @@ - + + @@ -1420,7 +1421,8 @@ - + + @@ -1478,9 +1480,9 @@ - - - + + + @@ -1527,7 +1529,8 @@ - + + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index a10e85f92b..212fa6e2a9 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1220,6 +1220,7 @@ function xmldb_main_upgrade($oldversion=0) { $table->addKeyInfo('categoryid', XMLDB_KEY_FOREIGN, array('categoryid'), 'grade_categories', array('id')); $table->addKeyInfo('scaleid', XMLDB_KEY_FOREIGN, array('scaleid'), 'scale', array('id')); $table->addKeyInfo('outcomeid', XMLDB_KEY_FOREIGN, array('outcomeid'), 'grade_outcomes', array('id')); + $table->addKeyInfo('userlogged', XMLDB_KEY_FOREIGN, array('userlogged'), 'user', array('id')); /// Adding indexes to table grade_items_history $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action')); @@ -1252,6 +1253,7 @@ function xmldb_main_upgrade($oldversion=0) { $table->addKeyInfo('oldid', XMLDB_KEY_FOREIGN, array('oldid'), 'grade_categories', array('id')); $table->addKeyInfo('courseid', XMLDB_KEY_FOREIGN, array('courseid'), 'course', array('id')); $table->addKeyInfo('parent', XMLDB_KEY_FOREIGN, array('parent'), 'grade_categories', array('id')); + $table->addKeyInfo('userlogged', XMLDB_KEY_FOREIGN, array('userlogged'), 'user', array('id')); /// Adding indexes to table grade_categories_history $table->addIndexInfo('action', XMLDB_INDEX_NOTUNIQUE, array('action')); @@ -1396,6 +1398,23 @@ function xmldb_main_upgrade($oldversion=0) { set_field('user', 'mnethostid', $CFG->mnet_localhost_id, 'username', 'guest'); } + if ($result && $oldversion < 2007070900) { + // fix loggeduser foreign key + $tables = array('grade_categories_history', + 'scale_history', + 'grade_items_history', + 'grade_grades_history', + 'grade_grades_text_history', + 'grade_outcomes_history'); + + foreach ($tables as $table) { + $table = new XMLDBTable($table); + $key = new XMLDBKey('userlogged'); + $key->setAttributes(XMLDB_KEY_FOREIGN, array('userlogged'), 'user', array('id')); + add_key($table, $key); + } + } + return $result; } diff --git a/version.php b/version.php index 1896cc8aa2..ecbb6e1069 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2007070603; // YYYYMMDD = date + $version = 2007070900; // YYYYMMDD = date // XY = increments within a single day $release = '1.9 dev'; // Human-friendly version name