diff --git a/backup/moodle2/backup_hvp_stepslib.php b/backup/moodle2/backup_hvp_stepslib.php
index 398ea0860..eadf1869b 100644
--- a/backup/moodle2/backup_hvp_stepslib.php
+++ b/backup/moodle2/backup_hvp_stepslib.php
@@ -56,7 +56,7 @@ protected function define_structure() {
'json_content',
'embed_type',
'disable',
- 'content_type',
+ 'contenttype',
'source',
'year_from',
'year_to',
@@ -103,7 +103,7 @@ protected function define_structure() {
h.json_content,
h.embed_type,
h.disable,
- h.content_type,
+ h.contenttype,
h.slug,
h.timecreated,
h.timemodified,
diff --git a/backup/moodle2/restore_hvp_stepslib.php b/backup/moodle2/restore_hvp_stepslib.php
index 75c493015..263b37247 100644
--- a/backup/moodle2/restore_hvp_stepslib.php
+++ b/backup/moodle2/restore_hvp_stepslib.php
@@ -73,6 +73,12 @@ protected function process_hvp($data) {
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->timemodified = $this->apply_date_offset($data->timemodified);
+ // Allow old backups to work after renaming content_type.
+ if (property_exists($data, 'content_type')) {
+ $data->contenttype = $data->content_type;
+ unset($data->content_type);
+ }
+
// Insert the hvp record.
$newitemid = $DB->insert_record('hvp', $data);
// Immediately after inserting "activity" record, call this.
diff --git a/db/install.xml b/db/install.xml
index 46e7498ec..db4236e42 100644
--- a/db/install.xml
+++ b/db/install.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/db/upgrade.php b/db/upgrade.php
index dcad1a6a5..b7dca585f 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -567,6 +567,23 @@ function hvp_upgrade_2020112600() {
}
}
+/**
+ * Rename content_type since it was added as a reserved word in Aurora MySQL version 3.06.0.
+ */
+function hvp_upgrade_2023122501() {
+ global $DB;
+ $dbman = $DB->get_manager();
+
+ // Rename field content_type on table hvp to contenttype.
+ $table = new xmldb_table('hvp');
+ $field = new xmldb_field('content_type', XMLDB_TYPE_CHAR, '127', null, null, null, null, 'main_library_id');
+
+ // Launch rename field content_type.
+ if ($dbman->field_exists($table, $field)) {
+ $dbman->rename_field($table, $field, 'contenttype');
+ }
+}
+
/**
* Hvp module upgrade function.
*
@@ -593,6 +610,7 @@ function xmldb_hvp_upgrade($oldversion) {
2020082800,
2020091500,
2020112600,
+ 2023122501,
];
foreach ($upgrades as $version) {
diff --git a/version.php b/version.php
index 06fa5b7a2..f093c21bb 100644
--- a/version.php
+++ b/version.php
@@ -23,7 +23,7 @@
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2023122500;
+$plugin->version = 2023122501;
$plugin->requires = 2013051403;
$plugin->cron = 0;
$plugin->component = 'mod_hvp';