Skip to content
Browse files

mnet: polish db changes to match upgrade and clean inst

  • Loading branch information...
1 parent 5cd129c commit 357f08fa494c4d6296e61569c20ac1832120e08a martinlanghoff committed
Showing with 45 additions and 20 deletions.
  1. +41 −17 lib/db/install.xml
  2. +4 −3 lib/db/upgrade.php
View
58 lib/db/install.xml
@@ -524,7 +524,7 @@
<FIELD NAME="confirmed" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="auth" NEXT="policyagreed"/>
<FIELD NAME="policyagreed" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="confirmed" NEXT="deleted"/>
<FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="policyagreed" NEXT="mnethostid"/>
- <FIELD NAME="mnethostid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="deleted" NEXT="username"/>
+ <FIELD NAME="mnethostid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" UNSIGNED="false" SEQUENCE="false" ENUM="false" PREVIOUS="deleted" NEXT="username"/>
<FIELD NAME="username" TYPE="char" LENGTH="100" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="mnethostid" NEXT="password"/>
<FIELD NAME="password" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="username" NEXT="idnumber"/>
<FIELD NAME="idnumber" TYPE="char" LENGTH="64" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="password" NEXT="firstname"/>
@@ -979,9 +979,9 @@
<TABLE NAME="mnet_enrol_course" COMMENT="Information about courses on remote hosts" PREVIOUS="user_info_data" NEXT="mnet_enrol_assignments">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="Unique remote-course ID" NEXT="hostid"/>
- <FIELD NAME="hostid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="remoteid"/>
- <FIELD NAME="remoteid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Unique ID of course on its home server" ENUM="false" PREVIOUS="hostid" NEXT="cat_id"/>
- <FIELD NAME="cat_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="remoteid" NEXT="cat_name"/>
+ <FIELD NAME="hostid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="remoteid"/>
+ <FIELD NAME="remoteid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Unique ID of course on its home server" ENUM="false" PREVIOUS="hostid" NEXT="cat_id"/>
+ <FIELD NAME="cat_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="remoteid" NEXT="cat_name"/>
<FIELD NAME="cat_name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="cat_id" NEXT="cat_description"/>
<FIELD NAME="cat_description" TYPE="text" LENGTH="medium" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="cat_name" NEXT="sortorder"/>
<FIELD NAME="sortorder" TYPE="int" LENGTH="4" UNSIGNED="true" NOTNULL="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="cat_description" NEXT="fullname"/>
@@ -998,14 +998,16 @@
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_course table"/>
</KEYS>
+ <INDEXES>
+ <INDEX NAME="hostid_remoteid" UNIQUE="true" FIELDS="hostid, remoteid" />
+ </INDEXES>
</TABLE>
<TABLE NAME="mnet_enrol_assignments" COMMENT="Information about enrolments on courses on remote hosts" PREVIOUS="mnet_enrol_course" NEXT="mnet_host">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="Unique enrollment ID" NEXT="userid"/>
- <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Unique ID of user on *this* server" ENUM="false" PREVIOUS="id" NEXT="mnetcourseid"/>
- <FIELD NAME="mnetcourseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="hostid"/>
- <FIELD NAME="hostid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="mnetcourseid" NEXT="courseid"/>
- <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" COMMENT="Unique ID of course on its home server" ENUM="false" PREVIOUS="hostid" NEXT="rolename"/>
+ <FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Unique ID of user on *this* server" ENUM="false" PREVIOUS="id" NEXT="hostid"/>
+ <FIELD NAME="hostid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="courseid"/>
+ <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Unique ID of course on its home server" ENUM="false" PREVIOUS="hostid" NEXT="rolename"/>
<FIELD NAME="rolename" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="courseid" NEXT="enroltime"/>
<FIELD NAME="enroltime" TYPE="int" LENGTH="10" UNSIGNED="true" NOTNULL="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="rolename" NEXT="enroltype"/>
<FIELD NAME="enroltype" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="enroltime"/>
@@ -1013,14 +1015,18 @@
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_enrol_assignments table"/>
</KEYS>
+ <INDEXES>
+ <INDEX NAME="hostid_courseid" UNIQUE="false" FIELDS="hostid,courseid" NEXT="userid"/>
+ <INDEX NAME="userid" UNIQUE="false" FIELDS="userid" PREVIOUS="hostid_courseid"/>
+ </INDEXES>
</TABLE>
<TABLE NAME="mnet_host" COMMENT="Information about the local and remote hosts for RPC" PREVIOUS="mnet_enrol_assignments" NEXT="mnet_host2service">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="Unique Host ID" NEXT="deleted"/>
- <FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="wwwroot"/>
+ <FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="wwwroot"/>
<FIELD NAME="wwwroot" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="deleted" NEXT="ip_address"/>
<FIELD NAME="ip_address" TYPE="char" LENGTH="39" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="wwwroot" NEXT="name"/>
- <FIELD NAME="name" TYPE="char" LENGTH="80" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="ip_address" NEXT="public_key"/>
+ <FIELD NAME="name" TYPE="char" LENGTH="80" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="ip_address" NEXT="public_key"/>
<FIELD NAME="public_key" TYPE="text" LENGTH="medium" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="public_key_expires"/>
<FIELD NAME="public_key_expires" TYPE="int" LENGTH="10" UNSIGNED="true" NOTNULL="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="public_key" NEXT="transport"/>
<FIELD NAME="transport" TYPE="int" LENGTH="2" UNSIGNED="true" NOTNULL="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="public_key_expires" NEXT="portno"/>
@@ -1037,18 +1043,21 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" NEXT="hostid"/>
<FIELD NAME="hostid" TYPE="int" LENGTH="10" DEFAULT="0" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="serviceid"/>
<FIELD NAME="serviceid" TYPE="int" LENGTH="10" DEFAULT="0" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="hostid" NEXT="publish"/>
- <FIELD NAME="publish" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="serviceid" NEXT="subscribe"/>
- <FIELD NAME="subscribe" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="publish"/>
+ <FIELD NAME="publish" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="serviceid" NEXT="subscribe"/>
+ <FIELD NAME="subscribe" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="publish"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_host2service table"/>
</KEYS>
+ <INDEXES>
+ <INDEX NAME="hostid_serviceid" UNIQUE="true" FIELDS="hostid,serviceid"/>
+ </INDEXES>
</TABLE>
<TABLE NAME="mnet_log" COMMENT="Store session data from users migrating to other sites" PREVIOUS="mnet_host2service" NEXT="mnet_rpc">
<FIELDS>
- <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="hostid"/>
+ <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" NEXT="hostid"/>
<FIELD NAME="hostid" TYPE="int" LENGTH="10" DEFAULT="0" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" COMMENT="Unique host ID" PREVIOUS="id" NEXT="remoteid"/>
- <FIELD NAME="remoteid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="hostid" NEXT="time"/>
+ <FIELD NAME="remoteid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="hostid" NEXT="time"/>
<FIELD NAME="time" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="remoteid" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="time" NEXT="ip"/>
<FIELD NAME="ip" TYPE="char" LENGTH="15" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="userid" NEXT="course"/>
@@ -1063,6 +1072,9 @@
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_session table"/>
</KEYS>
+ <INDEXES>
+ <INDEX NAME="hostid_userid_course" UNIQUE="false" FIELDS="hostid, userid, course"/>
+ </INDEXES>
</TABLE>
<TABLE NAME="mnet_rpc" COMMENT="Functions or methods that we may publish or subscribe to" PREVIOUS="mnet_log" NEXT="mnet_service">
<FIELDS>
@@ -1071,13 +1083,16 @@
<FIELD NAME="xmlrpc_path" TYPE="char" LENGTH="80" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="function_name" NEXT="parent_type"/>
<FIELD NAME="parent_type" TYPE="char" LENGTH="6" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="xmlrpc_path" NEXT="parent"/>
<FIELD NAME="parent" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="parent_type" NEXT="enabled"/>
- <FIELD NAME="enabled" TYPE="int" LENGTH="2" UNSIGNED="true" NOTNULL="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="parent" NEXT="help"/>
+ <FIELD NAME="enabled" TYPE="int" LENGTH="1" UNSIGNED="true" NOTNULL="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="parent" NEXT="help"/>
<FIELD NAME="help" TYPE="text" LENGTH="medium" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="enabled" NEXT="profile"/>
<FIELD NAME="profile" TYPE="text" LENGTH="medium" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Method signature" PREVIOUS="help"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_rpc table"/>
</KEYS>
+ <INDEXES>
+ <INDEX NAME="enabled_xmlrpcpath" UNIQUE="false" FIELDS="enabled,xmlrpc_path"/>
+ </INDEXES>
</TABLE>
<TABLE NAME="mnet_service" COMMENT="A service is a group of functions" PREVIOUS="mnet_rpc" NEXT="mnet_service2rpc">
<FIELDS>
@@ -1085,7 +1100,7 @@
<FIELD NAME="name" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" ENUM="false" NEXT="description" PREVIOUS="id"/>
<FIELD NAME="description" TYPE="char" LENGTH="40" NOTNULL="true" SEQUENCE="false" ENUM="false" NEXT="apiversion" PREVIOUS="name"/>
<FIELD NAME="apiversion" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" ENUM="false" NEXT="offer" PREVIOUS="description"/>
- <FIELD NAME="offer" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Do we even offer this service?" ENUM="false" PREVIOUS="apiversion"/>
+ <FIELD NAME="offer" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Do we even offer this service?" ENUM="false" PREVIOUS="apiversion"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_service table"/>
@@ -1100,6 +1115,9 @@
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_service2rpc table"/>
</KEYS>
+ <INDEXES>
+ <INDEX NAME="rpcid_serviceid" UNIQUE="true" FIELDS="rpcid, serviceid"/>
+ </INDEXES>
</TABLE>
<TABLE NAME="mnet_session" COMMENT="Store session data from users migrating to other sites" PREVIOUS="mnet_service2rpc" NEXT="mnet_sso_access_control">
<FIELDS>
@@ -1116,17 +1134,23 @@
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_session table"/>
</KEYS>
+ <INDEXES>
+ <INDEX NAME="token" UNIQUE="true" FIELDS="token"/>
+ </INDEXES>
</TABLE>
<TABLE NAME="mnet_sso_access_control" COMMENT="Users by host permitted (or not) to login from a remote provider" PREVIOUS="mnet_session">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="Required ID field" NEXT="username"/>
<FIELD NAME="username" TYPE="char" LENGTH="100" DEFAULT="" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Username" PREVIOUS="id" NEXT="mnet_host_id"/>
- <FIELD NAME="mnet_host_id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="id of mnet host" PREVIOUS="username" NEXT="access"/>
+ <FIELD NAME="mnet_host_id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="id of mnet host" PREVIOUS="username" NEXT="access"/>
<FIELD NAME="access" TYPE="char" LENGTH="20" DEFAULT="allow" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Whether or not this user/host can login" PREVIOUS="mnet_host_id"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the mnet_sso_access_control table"/>
</KEYS>
+ <INDEXES>
+ <INDEX NAME="mnethostid_username" UNIQUE="true" FIELDS="mnet_host_id, username"/>
+ </INDEXES>
</TABLE>
</TABLES>
<STATEMENTS>
View
7 lib/db/upgrade.php
@@ -171,7 +171,7 @@ function xmldb_main_upgrade($oldversion=0) {
XMLDB_NOTNULL, null, null, null, '');
$f = $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '80', null,
XMLDB_NOTNULL, null, null, null, '');
- $f = $table->addFieldInfo('public_key', XMLDB_TYPE_TEXT, null, null,
+ $f = $table->addFieldInfo('public_key', XMLDB_TYPE_TEXT, 'medium', null,
XMLDB_NOTNULL, null, null, null, null);
$f = $table->addFieldInfo('public_key_expires', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
XMLDB_NOTNULL, null, null, null, 0);
@@ -287,6 +287,7 @@ function xmldb_main_upgrade($oldversion=0) {
$result = $result && create_table($table);
$table = new XMLDBTable('mnet_service2rpc');
+ $table->comment = 'Group functions or methods under a service';
// fields
$f = $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', false,
XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
@@ -363,7 +364,7 @@ function xmldb_main_upgrade($oldversion=0) {
XMLDB_NOTNULL, NULL, null, null, 0);
// PK and indexes
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
- $table->addIndexInfo('token', XMLDB_INDEX_NOTUNIQUE, array('token'));
+ $table->addIndexInfo('token', XMLDB_INDEX_UNIQUE, array('token'));
// Create the table
$result = $result && create_table($table);
@@ -449,7 +450,7 @@ function xmldb_main_upgrade($oldversion=0) {
// PK and indexes
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addIndexInfo('hostid_courseid', XMLDB_INDEX_NOTUNIQUE, array('hostid', 'courseid'));
- $table->addIndexInfo('userid', XMLDB_INDEX_UNIQUE, array('userid'));
+ $table->addIndexInfo('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
// Create the table
$result = $result && create_table($table);

0 comments on commit 357f08f

Please sign in to comment.
Something went wrong with that request. Please try again.