From 81f2bb81229f43fa3e1dcbc9f135e558029e09b1 Mon Sep 17 00:00:00 2001 From: skodak Date: Wed, 31 Dec 2008 12:24:19 +0000 Subject: [PATCH] MDL-14992 new database based session table - not used yet --- lib/db/install.xml | 30 +++++++++++++++++------------- lib/db/upgrade.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ version.php | 2 +- 3 files changed, 63 insertions(+), 14 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index e8552477079..53faf8a99f6 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 8fc44a831eb..37551b9d66d 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 f295eac61c2..75adf6dec77 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