From ac5efef6b50b976f97f1a8614ed86f741b206c33 Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Mon, 7 Jul 2008 15:09:40 +0000 Subject: [PATCH] MDL-15562 database tables, upgrade and version bump for portfolio API - portfolio_instance, portfolio_instance_user, portfolio_instance_config --- lib/db/install.xml | 44 ++++++++++++++++++++++++++++++-- lib/db/upgrade.php | 63 ++++++++++++++++++++++++++++++++++++++++++++++ version.php | 2 +- 3 files changed, 106 insertions(+), 3 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index d010413646..6e22adebd6 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1661,7 +1661,7 @@ - +
@@ -1677,11 +1677,51 @@ + + + + +
+ + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
@@ -1713,4 +1753,4 @@ - \ No newline at end of file + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index f004aaccb8..fbe8ab0be6 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -200,6 +200,69 @@ function xmldb_main_upgrade($oldversion=0) { upgrade_main_savepoint($result, 2008070700); } + if ($result && $oldversion < 2008070701) { + + /// Define table portfolio_instance to be created + $table = new xmldb_table('portfolio_instance'); + + /// Adding fields to table portfolio_instance + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->add_field('plugin', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, null, null); + $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null); + $table->add_field('visible', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1'); + + /// Adding keys to table portfolio_instance + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + + /// Conditionally launch create table for portfolio_instance + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + /// Define table portfolio_instance_config to be created + $table = new xmldb_table('portfolio_instance_config'); + + /// Adding fields to table portfolio_instance_config + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->add_field('instance', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null); + $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null); + $table->add_field('value', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null); + + /// Adding keys to table portfolio_instance_config + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('instance', XMLDB_KEY_FOREIGN, array('instance'), 'portfolio_instance', array('id')); + + /// Adding indexes to table portfolio_instance_config + $table->add_index('name', XMLDB_INDEX_NOTUNIQUE, array('name')); + + /// Conditionally launch create table for portfolio_instance_config + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + /// Define table portfolio_instance_user to be created + $table = new xmldb_table('portfolio_instance_user'); + + /// Adding fields to table portfolio_instance_user + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->add_field('instance', 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('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null); + $table->add_field('value', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null); + + /// Adding keys to table portfolio_instance_user + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('instancefk', XMLDB_KEY_FOREIGN, array('instance'), 'portfolio_instance', array('id')); + $table->add_key('userfk', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id')); + + /// Conditionally launch create table for portfolio_instance_user + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + /// Main savepoint reached + upgrade_main_savepoint($result, 2008070701); + } + /* * TODO: * drop adodb_logsql table and create a new general sql log table diff --git a/version.php b/version.php index 5e8431e858..0bc5023b0a 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 = 2008070700; // YYYYMMDD = date of the last version bump + $version = 2008070701; // YYYYMMDD = date of the last version bump // XX = daily increments $release = '2.0 dev (Build: 20080707)'; // Human-friendly version name -- 2.39.5