MDL-15562 database tables, upgrade and version bump for portfolio API

- portfolio_instance, portfolio_instance_user, portfolio_instance_config
This commit is contained in:
mjollnir_
2008-07-07 15:09:40 +00:00
parent b373260475
commit ac5efef6b5
3 changed files with 106 additions and 3 deletions
+42 -2
View File
@@ -1661,7 +1661,7 @@
<INDEX NAME="expiry" UNIQUE="false" FIELDS="expiry" PREVIOUS="path"/>
</INDEXES>
</TABLE>
<TABLE NAME="repository" COMMENT="This table contains one entry for every configured external repository instance." PREVIOUS="webdav_locks">
<TABLE NAME="repository" COMMENT="This table contains one entry for every configured external repository instance." PREVIOUS="webdav_locks" NEXT="portfolio_instance">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="repositoryname"/>
<FIELD NAME="repositoryname" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="repositorytype"/>
@@ -1677,11 +1677,51 @@
<FIELD NAME="data5" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="data4" NEXT="timecreated"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="data5" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="timecreated"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="portfolio_instance" COMMENT="base table (not including config data) for instances of portfolio plugins." PREVIOUS="repository" NEXT="portfolio_instance_config">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="plugin"/>
<FIELD NAME="plugin" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="fk to plugin" PREVIOUS="id" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="name of plugin instance" PREVIOUS="plugin" NEXT="visible"/>
<FIELD NAME="visible" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" COMMENT="whether this instance is visible or not" PREVIOUS="name"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="portfolio_instance_config" COMMENT="config for portfolio plugin instances" PREVIOUS="portfolio_instance" NEXT="portfolio_instance_user">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="instance"/>
<FIELD NAME="instance" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="instance of plugin we're configurating" PREVIOUS="id" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="config field" PREVIOUS="instance" NEXT="value"/>
<FIELD NAME="value" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="config value" PREVIOUS="name"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="instance"/>
<KEY NAME="instance" TYPE="foreign" FIELDS="instance" REFTABLE="portfolio_instance" REFFIELDS="id" COMMENT="fk to plugin instance" PREVIOUS="primary"/>
</KEYS>
<INDEXES>
<INDEX NAME="name" UNIQUE="false" FIELDS="name" COMMENT="name index"/>
</INDEXES>
</TABLE>
<TABLE NAME="portfolio_instance_user" COMMENT="user data for portfolio instances." PREVIOUS="portfolio_instance_config">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="instance"/>
<FIELD NAME="instance" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="fk to instance table" PREVIOUS="id" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="fk to user table" PREVIOUS="instance" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="name of config item" PREVIOUS="userid" NEXT="value"/>
<FIELD NAME="value" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="value of config item" PREVIOUS="name"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="instancefk"/>
<KEY NAME="instancefk" TYPE="foreign" FIELDS="instance" REFTABLE="portfolio_instance" REFFIELDS="id" COMMENT="fk to portfolio_instance" PREVIOUS="primary" NEXT="userfk"/>
<KEY NAME="userfk" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id" COMMENT="fk to user table" PREVIOUS="instancefk"/>
</KEYS>
</TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert mnet_application" TYPE="insert" TABLE="mnet_application" COMMENT="Initial insert of records on table mnet_application" NEXT="insert log_display">
@@ -1713,4 +1753,4 @@
</SENTENCES>
</STATEMENT>
</STATEMENTS>
</XMLDB>
</XMLDB>
+63
View File
@@ -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
+1 -1
View File
@@ -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