Commit f5a9c0ed authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1795597: Install/upgrade LTI tables for mysql



Moved the adding of indexes to post install so we can differentiate
between postgres and mysql as they need to set up the indexes on
'text' fields differently

behatnotneeded

Change-Id: I73fb277741528bad1135912b4c743788a7b90bd1
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent c4c910d7
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<TABLE NAME="lti_assessment"> <TABLE NAME="lti_assessment">
<FIELDS> <FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" /> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
<FIELD NAME="oauthserver" TYPE="int" LENGTH="10" NOTNULL="true" /> <FIELD NAME="oauthserver" TYPE="int" LENGTH="10" UNSIGNED="true" SEQUENCE="false" NOTNULL="true" />
<FIELD NAME="resourcelinkid" TYPE="text" NOTNULL="true" /> <FIELD NAME="resourcelinkid" TYPE="text" NOTNULL="true" />
<FIELD NAME="contextid" TYPE="text" NOTNULL="true" /> <FIELD NAME="contextid" TYPE="text" NOTNULL="true" />
<FIELD NAME="lisoutcomeserviceurl" TYPE="text" NOTNULL="true" /> <FIELD NAME="lisoutcomeserviceurl" TYPE="text" NOTNULL="true" />
...@@ -24,10 +24,6 @@ ...@@ -24,10 +24,6 @@
<KEY NAME="oauthserverregistryfk" TYPE="foreign" FIELDS="oauthserver" REFTABLE="oauth_server_registry" REFFIELDS="id" /> <KEY NAME="oauthserverregistryfk" TYPE="foreign" FIELDS="oauthserver" REFTABLE="oauth_server_registry" REFFIELDS="id" />
<KEY NAME="groupfk" TYPE="foreign" FIELDS="group" REFTABLE="group" REFFIELDS="id" /> <KEY NAME="groupfk" TYPE="foreign" FIELDS="group" REFTABLE="group" REFFIELDS="id" />
</KEYS> </KEYS>
<INDEXES>
<INDEX NAME="resourcelinkididx" UNIQUE="false" FIELDS="resourcelinkid" />
<INDEX NAME="contextididx" UNIQUE="false" FIELDS="contextid" />
</INDEXES>
</TABLE> </TABLE>
<TABLE NAME="lti_assessment_submission"> <TABLE NAME="lti_assessment_submission">
<FIELDS> <FIELDS>
...@@ -49,9 +45,6 @@ ...@@ -49,9 +45,6 @@
<KEY NAME="viewfk" TYPE="foreign" FIELDS="viewid" REFTABLE="view" REFFIELDS="id" /> <KEY NAME="viewfk" TYPE="foreign" FIELDS="viewid" REFTABLE="view" REFFIELDS="id" />
<KEY NAME="ltiassessmentfk" TYPE="foreign" FIELDS="ltiassessment" REFTABLE="lti_assessment" REFFIELDS="id" /> <KEY NAME="ltiassessmentfk" TYPE="foreign" FIELDS="ltiassessment" REFTABLE="lti_assessment" REFFIELDS="id" />
</KEYS> </KEYS>
<INDEXES>
<INDEX NAME="lisresultsourceididx" UNIQUE="false" FIELDS="lisresultsourceid" />
</INDEXES>
</TABLE> </TABLE>
</TABLES> </TABLES>
</XMLDB> </XMLDB>
...@@ -22,7 +22,7 @@ function xmldb_module_lti_upgrade($oldversion=0) { ...@@ -22,7 +22,7 @@ function xmldb_module_lti_upgrade($oldversion=0) {
$table = new XMLDBTable('lti_assessment'); $table = new XMLDBTable('lti_assessment');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE); $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->addFieldInfo('oauthserver', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL); $table->addFieldInfo('oauthserver', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
$table->addFieldInfo('resourcelinkid', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL); $table->addFieldInfo('resourcelinkid', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('contextid', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL); $table->addFieldInfo('contextid', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL);
$table->addFieldInfo('lisoutcomeserviceurl', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL); $table->addFieldInfo('lisoutcomeserviceurl', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL);
...@@ -38,9 +38,6 @@ function xmldb_module_lti_upgrade($oldversion=0) { ...@@ -38,9 +38,6 @@ function xmldb_module_lti_upgrade($oldversion=0) {
$table->addKeyInfo('oauthserverregistryfk', XMLDB_KEY_FOREIGN, array('oauthserver'), 'oauth_server_registry', array('id')); $table->addKeyInfo('oauthserverregistryfk', XMLDB_KEY_FOREIGN, array('oauthserver'), 'oauth_server_registry', array('id'));
$table->addKeyInfo('groupfk', XMLDB_KEY_FOREIGN, array('group'), 'group', array('id')); $table->addKeyInfo('groupfk', XMLDB_KEY_FOREIGN, array('group'), 'group', array('id'));
$table->addIndexInfo('resourcelinkididx', XMLDB_INDEX_NOTUNIQUE, array('resourcelinkid'));
$table->addIndexInfo('contextididx', XMLDB_INDEX_NOTUNIQUE, array('contextid'));
create_table($table); create_table($table);
log_debug('Adding "lti_assessment_submission" table'); log_debug('Adding "lti_assessment_submission" table');
...@@ -63,8 +60,6 @@ function xmldb_module_lti_upgrade($oldversion=0) { ...@@ -63,8 +60,6 @@ function xmldb_module_lti_upgrade($oldversion=0) {
$table->addKeyInfo('ltiassessmentfk', XMLDB_KEY_FOREIGN, array('ltiassessment'), 'lti_assessment', array('id')); $table->addKeyInfo('ltiassessmentfk', XMLDB_KEY_FOREIGN, array('ltiassessment'), 'lti_assessment', array('id'));
$table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('viewid'), 'view', array('id')); $table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('viewid'), 'view', array('id'));
$table->addIndexInfo('lisresultsourceididx', XMLDB_INDEX_NOTUNIQUE, array('lisresultsourceid'));
create_table($table); create_table($table);
} }
......
...@@ -25,6 +25,31 @@ class PluginModuleLti extends PluginModule { ...@@ -25,6 +25,31 @@ class PluginModuleLti extends PluginModule {
); );
public static function postinst($fromversion) { public static function postinst($fromversion) {
if ($fromversion < 2018100100) {
// Add indexes to the lit_assessment table on install
log_debug('Add indexes to lti_assessment table');
$mysqlsuffix = is_mysql() ? '(255)' : '';
$table = new XMLDBTable('lti_assessment');
$field = new XMLDBField('resourcelinkid');
if (field_exists($table, $field)) {
$index = new XMLDBIndex('resourcelinkididx');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('resourcelinkid' . $mysqlsuffix));
add_index($table, $index);
}
$field = new XMLDBField('contextid');
if (field_exists($table, $field)) {
$index = new XMLDBIndex('contextididx');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('contextid' . $mysqlsuffix));
add_index($table, $index);
}
$field = new XMLDBField('listresultsourceid');
if (field_exists($table, $field)) {
$index = new XMLDBIndex('lisresultsourceididx');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('lisresultsourceid' . $mysqlsuffix));
add_index($table, $index);
}
}
require_once(get_config('docroot') . 'webservice/lib.php'); require_once(get_config('docroot') . 'webservice/lib.php');
external_reload_component('module/lti', false); external_reload_component('module/lti', false);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment