diff --git a/lib/db/install.xml b/lib/db/install.xml index 83cb16afea4..e5d4b8767ba 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<XMLDB PATH="lib/db" VERSION="20090719" COMMENT="XMLDB file for core Moodle tables" +<XMLDB PATH="lib/db" VERSION="20090911" COMMENT="XMLDB file for core Moodle tables" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd" > @@ -2264,36 +2264,36 @@ <KEY NAME="primary" TYPE="primary" FIELDS="id"/> </KEYS> </TABLE> - <TABLE NAME="external_functions" COMMENT="Each of these is a function" PREVIOUS="comments" NEXT="external_services"> + <TABLE NAME="external_functions" COMMENT="external functions" PREVIOUS="comments" NEXT="external_services"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="component"/> - <FIELD NAME="component" TYPE="char" LENGTH="100" NOTNULL="true" PREVIOUS="id" NEXT="name"/> + <FIELD NAME="component" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="name"/> <FIELD NAME="name" TYPE="char" LENGTH="150" NOTNULL="true" SEQUENCE="false" PREVIOUS="component" NEXT="phpfile"/> - <FIELD NAME="phpfile" TYPE="char" LENGTH="255" NOTNULL="false" PREVIOUS="name" NEXT="contextrestriction"/> - <FIELD NAME="contextrestriction" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" PREVIOUS="phpfile"/> + <FIELD NAME="phpfile" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="name" NEXT="contextrestriction"/> + <FIELD NAME="contextrestriction" TYPE="int" LENGTH="1" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" PREVIOUS="phpfile"/> </FIELDS> <KEYS> <KEY NAME="primary" TYPE="primary" FIELDS="id"/> </KEYS> </TABLE> - <TABLE NAME="external_services" COMMENT="Each of these is a service" PREVIOUS="external_functions" NEXT="external_services_functions"> + <TABLE NAME="external_services" COMMENT="external services" PREVIOUS="external_functions" NEXT="external_services_functions"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/> <FIELD NAME="name" TYPE="char" LENGTH="150" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="enabled"/> - <FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" SEQUENCE="false" PREVIOUS="name" NEXT="custom"/> - <FIELD NAME="custom" TYPE="int" LENGTH="1" NOTNULL="true" PREVIOUS="enabled" NEXT="customname"/> - <FIELD NAME="customname" TYPE="char" LENGTH="150" NOTNULL="false" PREVIOUS="custom"/> + <FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="name" NEXT="custom"/> + <FIELD NAME="custom" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="enabled" NEXT="customname"/> + <FIELD NAME="customname" TYPE="char" LENGTH="150" NOTNULL="false" SEQUENCE="false" PREVIOUS="custom"/> </FIELDS> <KEYS> <KEY NAME="primary" TYPE="primary" FIELDS="id"/> </KEYS> </TABLE> - <TABLE NAME="external_services_functions" COMMENT="Each of these is a link service/function" PREVIOUS="external_services"> + <TABLE NAME="external_services_functions" COMMENT="association between external functions and external services" PREVIOUS="external_services"> <FIELDS> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="externalserviceid"/> - <FIELD NAME="externalserviceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" PREVIOUS="id" NEXT="externalfunctionid"/> - <FIELD NAME="externalfunctionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" PREVIOUS="externalserviceid" NEXT="enabled"/> - <FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" SEQUENCE="false" PREVIOUS="externalfunctionid"/> + <FIELD NAME="externalserviceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="id" NEXT="externalfunctionid"/> + <FIELD NAME="externalfunctionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" PREVIOUS="externalserviceid" NEXT="enabled"/> + <FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" PREVIOUS="externalfunctionid"/> </FIELDS> <KEYS> <KEY NAME="primary" TYPE="primary" FIELDS="id"/> diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 20504dfc0c0..58fecf4c223 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2554,6 +2554,96 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); } upgrade_main_savepoint($result, 2009090800); } + + if ($result && $oldversion < 2009090803) { + + /// Define table external_functions to be dropped + $table = new xmldb_table('external_functions'); + + /// Conditionally launch drop table for external_functions + if ($dbman->table_exists($table)) { + $dbman->drop_table($table); + } + + + + /// Define table external_services to be dropped + $table = new xmldb_table('external_services'); + + /// Conditionally launch drop table for external_services + if ($dbman->table_exists($table)) { + $dbman->drop_table($table); + } + + + /// Define table external_services_functions to be dropped + $table = new xmldb_table('external_services_functions'); + + /// Conditionally launch drop table for external_services_functions + if ($dbman->table_exists($table)) { + $dbman->drop_table($table); + } + + + /// Define table external_functions to be created + $table = new xmldb_table('external_functions'); + + /// Adding fields to table external_functions + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('component', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null); + $table->add_field('name', XMLDB_TYPE_CHAR, '150', null, XMLDB_NOTNULL, null, null); + $table->add_field('phpfile', XMLDB_TYPE_CHAR, '255', null, null, null, null); + $table->add_field('contextrestriction', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null); + + /// Adding keys to table external_functions + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + + /// Conditionally launch create table for external_functions + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + + /// Define table external_services to be created + $table = new xmldb_table('external_services'); + + /// Adding fields to table external_services + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('name', XMLDB_TYPE_CHAR, '150', null, XMLDB_NOTNULL, null, null); + $table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null); + $table->add_field('custom', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null); + $table->add_field('customname', XMLDB_TYPE_CHAR, '150', null, null, null, null); + + /// Adding keys to table external_services + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + + /// Conditionally launch create table for external_services + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + + /// Define table external_services_functions to be created + $table = new xmldb_table('external_services_functions'); + + /// Adding fields to table external_services_functions + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('externalserviceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('externalfunctionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null); + $table->add_field('enabled', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, null); + + /// Adding keys to table external_services_functions + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + + /// Conditionally launch create table for external_services_functions + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + /// Main savepoint reached + upgrade_main_savepoint($result, 2009090803); + } + return $result; } diff --git a/version.php b/version.php index a20f81ae99e..b1ff9261e93 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 = 2009090800; // YYYYMMDD = date of the last version bump + $version = 2009090803; // YYYYMMDD = date of the last version bump // XX = daily increments - $release = '2.0 dev (Build: 20090911)'; // Human-friendly version name + $release = '2.0 dev (Build: 20090912)'; // Human-friendly version name