Skip to content

Commit

Permalink
MDL-49795 mod_book: Add foreign key for course
Browse files Browse the repository at this point in the history
  • Loading branch information
keevan committed Aug 3, 2022
1 parent af71e4f commit c216725
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion mod/book/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="mod/book/db" VERSION="20200907" COMMENT="XMLDB file for Moodle mod_book"
<XMLDB PATH="mod/book/db" VERSION="20220530" COMMENT="XMLDB file for Moodle mod_book"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
Expand All @@ -20,6 +20,7 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="course" TYPE="foreign" FIELDS="course" REFTABLE="course" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="book_chapters" COMMENT="Defines book_chapters">
Expand Down
10 changes: 10 additions & 0 deletions mod/book/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ function xmldb_book_upgrade($oldversion) {

// Automatically generated Moodle v4.0.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2022053000) {
// Define key course (foreign) to be added to book.
$table = new xmldb_table('book');
$key = new xmldb_key('course', XMLDB_KEY_FOREIGN, ['course'], 'course', ['id']);
// Launch add key course.
$dbman->add_key($table, $key);

// Book savepoint reached.
upgrade_mod_savepoint(true, 2022053000, 'book');
}

return true;
}
2 changes: 1 addition & 1 deletion mod/book/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
defined('MOODLE_INTERNAL') || die;

$plugin->component = 'mod_book'; // Full name of the plugin (used for diagnostics)
$plugin->version = 2022041900; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2022053000; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2022041200; // Requires this Moodle version.
$plugin->cron = 0; // Period for cron to check this module (secs)

0 comments on commit c216725

Please sign in to comment.