From ff2f69bc7c95301b3cc3fc114502b9a97c2fd03c Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Tue, 19 Aug 2008 15:02:46 +0000 Subject: [PATCH] MDL-16046 - beginning of, adding userid field to portfolio tempdata --- lib/db/install.xml | 8 +++++--- lib/db/upgrade.php | 28 ++++++++++++++++++++++++++++ version.php | 2 +- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index 55417de27c..22f23a1ef0 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -1880,10 +1880,12 @@ - + + - + + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 872e255e19..1ec8bec714 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -672,6 +672,34 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint($result, 2008081600); } + if ($result && $oldversion < 2008081900) { + /// Define field userid to be added to portfolio_tempdata + $table = new xmldb_table('portfolio_tempdata'); + $field = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'expirytime'); + + /// Conditionally launch add field userid + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + $DB->set_field('portfolio_tempdata', 'userid', 0); + /// now change it to be notnull + + /// Changing nullability of field userid on table portfolio_tempdata to not null + $field = new xmldb_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'expirytime'); + + /// Launch change of nullability for field userid + $dbman->change_field_notnull($table, $field); + + /// Define key userfk (foreign) to be added to portfolio_tempdata + $table = new xmldb_table('portfolio_tempdata'); + $key = new xmldb_key('userfk', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); + + /// Launch add key userfk + $dbman->add_key($table, $key); + + upgrade_main_savepoint($result, 2008081900); + } + return $result; } diff --git a/version.php b/version.php index a922895f19..cdd99a0498 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 = 2008081600; // YYYYMMDD = date of the last version bump + $version = 2008081900; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20080819)'; // Human-friendly version name -- 2.39.5