Skip to content

Commit

Permalink
fix field default value error in local_o365
Browse files Browse the repository at this point in the history
  • Loading branch information
weilai-irl committed Mar 12, 2024
1 parent d5ba911 commit 3d358bc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
<FIELD NAME="teamname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="courseshortname" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="requeststatus" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="false" DEFAULT="null" SEQUENCE="false"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
Expand Down
18 changes: 18 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -1141,5 +1141,23 @@ function xmldb_local_o365_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2023100907, 'local', 'o365');
}

if ($oldversion < 2023100911) {
$sql = 'UPDATE {local_o365_course_request} SET courseid = 0 WHERE courseid IS NULL';
$DB->execute($sql);

// Changing the default of field courseid on table local_o365_course_request to 0.
$table = new xmldb_table('local_o365_course_request');
$field = new xmldb_field('courseid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0', 'requeststatus');

// Launch change of default for field courseid.
$dbman->change_field_default($table, $field);

// Launch change of nullability for field courseid.
$dbman->change_field_notnull($table, $field);

// O365 savepoint reached.
upgrade_plugin_savepoint(true, 2023100911, 'local', 'o365');
}

return true;
}
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

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

$plugin->version = 2023100910;
$plugin->version = 2023100911;
$plugin->requires = 2023100900;
$plugin->release = '4.3.1';
$plugin->release = '4.3.2';
$plugin->component = 'local_o365';
$plugin->maturity = MATURITY_STABLE;
$plugin->dependencies = [
Expand Down

0 comments on commit 3d358bc

Please sign in to comment.