Skip to content

Commit

Permalink
report_customlang: regenerate foreign key after recent tables rename
Browse files Browse the repository at this point in the history
Thanks to Tim Hunt for spotting this overlooked key definition.
  • Loading branch information
mudrd8mz committed Nov 15, 2010
1 parent 8231bb1 commit c0b7391
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 4 additions & 4 deletions admin/report/customlang/db/install.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="admin/report/customlang/db" VERSION="20101112" COMMENT="XMLDB file for Moodle admin/report/customlang"
<XMLDB PATH="admin/report/customlang/db" VERSION="20101115" COMMENT="XMLDB file for Moodle admin/report/customlang"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
>
Expand All @@ -20,13 +20,13 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="fk_component"/>
<KEY NAME="fk_component" TYPE="foreign" FIELDS="componentid" REFTABLE="customlang_components" REFFIELDS="id" PREVIOUS="primary"/>
<KEY NAME="fk_component" TYPE="foreign" FIELDS="componentid" REFTABLE="report_customlang_components" REFFIELDS="id" PREVIOUS="primary"/>
</KEYS>
<INDEXES>
<INDEX NAME="uq_lang_component_string" UNIQUE="true" FIELDS="lang, componentid, stringid" COMMENT="For a given language and component, string identifiers must be unique"/>
</INDEXES>
</TABLE>
<TABLE NAME="report_customlang_components" COMMENT="Contains the list of all installed plugins that provide their own language pack " PREVIOUS="report_customlang">
<TABLE NAME="report_customlang_components" COMMENT="Contains the list of all installed plugins that provide their own language pack" PREVIOUS="report_customlang">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The normalized name of the plugin" PREVIOUS="id" NEXT="version"/>
Expand All @@ -37,4 +37,4 @@
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
14 changes: 14 additions & 0 deletions admin/report/customlang/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,19 @@ function xmldb_report_customlang_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2010111200, 'report', 'customlang');
}

/**
* Regenerate the foreign key after the tables rename
*/
if ($oldversion < 2010111500) {
$table = new xmldb_table('report_customlang');
$oldkey = new xmldb_key('fk_component', XMLDB_KEY_FOREIGN, array('componentid'), 'customlang_components', array('id'));
$newkey = new xmldb_key('fk_component', XMLDB_KEY_FOREIGN, array('componentid'), 'report_customlang_components', array('id'));

$dbman->drop_key($table, $oldkey);
$dbman->add_key($table, $newkey);

upgrade_plugin_savepoint(true, 2010111500, 'report', 'customlang');
}

return $result;
}
2 changes: 1 addition & 1 deletion admin/report/customlang/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2010111200;
$plugin->version = 2010111500;
$plugin->requires = 2010111002;

0 comments on commit c0b7391

Please sign in to comment.