From: skodak Date: Wed, 31 Dec 2008 12:24:19 +0000 (+0000) Subject: MDL-14992 new database based session table - not used yet X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=81f2bb81229f43fa3e1dcbc9f135e558029e09b1;p=moodle.git MDL-14992 new database based session table - not used yet --- diff --git a/lib/db/install.xml b/lib/db/install.xml index e855247707..53faf8a99f 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -401,7 +401,7 @@ - +
@@ -418,24 +418,28 @@
- +
- - - - - - + + + + + + + + - + + - - + + +
- +
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 8fc44a831e..37551b9d66 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -1165,6 +1165,51 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint($result, 2008121701); } + if ($result && $oldversion < 2008123100) { + + /// Define table sessions to be dropped + $table = new xmldb_table('sessions2'); + + /// Conditionally launch drop table for sessions + if ($dbman->table_exists($table)) { + $dbman->drop_table($table); + } + + /// Main savepoint reached + upgrade_main_savepoint($result, 2008123100); + } + + if ($result && $oldversion < 2008123101) { + + /// Define table sessions to be created + $table = new xmldb_table('sessions'); + + /// Adding fields to table sessions + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->add_field('sid', XMLDB_TYPE_CHAR, '128', null, XMLDB_NOTNULL, null, null, null, null); + $table->add_field('sessdata', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null); + $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + $table->add_field('lastip', XMLDB_TYPE_CHAR, '40', null, null, null, null, null, null); + $table->add_field('sesskey', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, null, null); + + /// Adding keys to table sessions + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); + + /// Adding indexes to table sessions + $table->add_index('sid', XMLDB_INDEX_UNIQUE, array('sid')); + $table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, array('timecreated')); + $table->add_index('timemodified', XMLDB_INDEX_NOTUNIQUE, array('timemodified')); + + /// Launch create table for sessions + $dbman->create_table($table); + + /// Main savepoint reached + upgrade_main_savepoint($result, 2008123101); + } + return $result; } diff --git a/version.php b/version.php index f295eac61c..75adf6dec7 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 = 2008121701; // YYYYMMDD = date of the last version bump + $version = 2008123101; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20081231)'; // Human-friendly version name