Skip to content

Commit

Permalink
DB: Add missing mapping table
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Dec 7, 2020
1 parent 6b31028 commit 4459572
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

## [2020120700] - 2020-12-07
### Fixed
- Test Connection script should respect configured OAuth setting
- Corrected admin setting path for test connection script
- Fixed missing database table

### Changed
- Corrected php docblock for testconnection.php script
Expand Down
21 changes: 21 additions & 0 deletions db/install.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="enrol/oneroster/db" VERSION="20201207" COMMENT="XMLDB file for Moodle enrol/oneroster"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="enrol_oneroster_user_map" COMMENT="Table to map OneRoster sourcedIds to a canonical id">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="parentid" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="mappedid" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="mappedid" UNIQUE="false" FIELDS="mappedid"/>
</INDEXES>
</TABLE>
</TABLES>
</XMLDB>
58 changes: 58 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* OneRoster enrolment plugin upgrade.
*
* @package enrol_oneroster
* @copyright 2020 Andrew Nicols <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

function xmldb_enrol_oneroster_upgrade($oldversion) {
global $DB;

$dbman = $DB->get_manager();

if ($oldversion < 2020120700) {

// Define table enrol_oneroster_user_map to be created.
$table = new xmldb_table('enrol_oneroster_user_map');

// Adding fields to table enrol_oneroster_user_map.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('parentid', XMLDB_TYPE_CHAR, '255', null, null, null, null);
$table->add_field('mappedid', XMLDB_TYPE_CHAR, '255', null, null, null, null);

// Adding keys to table enrol_oneroster_user_map.
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);

// Adding indexes to table enrol_oneroster_user_map.
$table->add_index('mappedid', XMLDB_INDEX_NOTUNIQUE, ['mappedid']);

// Conditionally launch create table for enrol_oneroster_user_map.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}

// Oneroster savepoint reached.
upgrade_plugin_savepoint(true, 2020120700, 'enrol', 'oneroster');
}

return true;
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

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

$plugin->version = 2020120301; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2020120700; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2019052000; // Requires this Moodle version.
$plugin->component = 'enrol_oneroster'; // Full name of the plugin (used for diagnostics).
$plugin->release = '2020-12-03';
Expand Down

0 comments on commit 4459572

Please sign in to comment.