From fe1031244b3e53ac4b42d10becb933bb9579b7e8 Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Wed, 16 Sep 2020 10:50:48 +0800 Subject: [PATCH] MDL-59510 core_oauth2: add oauth2_refresh_token table --- lib/db/install.xml | 19 +++++++++++++++++++ lib/db/upgrade.php | 30 ++++++++++++++++++++++++++++++ version.php | 2 +- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index 0643897ce64..a78c07b9b99 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -4300,5 +4300,24 @@ + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index cbfdccfc426..0e805474725 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2708,5 +2708,35 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2020091800.01); } + if ($oldversion < 2020100200.01) { + // Define table oauth2_refresh_token to be created. + $table = new xmldb_table('oauth2_refresh_token'); + + // Adding fields to table oauth2_refresh_token. + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); + $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); + $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); + $table->add_field('issuerid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); + $table->add_field('token', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null); + $table->add_field('scopehash', XMLDB_TYPE_CHAR, 40, null, XMLDB_NOTNULL, null, null); + + // Adding keys to table oauth2_refresh_token. + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); + $table->add_key('issueridkey', XMLDB_KEY_FOREIGN, ['issuerid'], 'oauth2_issuer', ['id']); + $table->add_key('useridkey', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); + + // Adding indexes to table oauth2_refresh_token. + $table->add_index('userid-issuerid-scopehash', XMLDB_INDEX_UNIQUE, array('userid', 'issuerid', 'scopehash')); + + // Conditionally launch create table for oauth2_refresh_token. + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2020100200.01); + } + return true; } diff --git a/version.php b/version.php index 9e4637903f4..e199dc72645 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2020100200.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2020100200.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '3.10dev+ (Build: 20201002)';// Human-friendly version name -- 2.43.0