Hi -
One of my plugins uses a fieldname of 'rank', which as of MySQL 8.0.1 has become a reserved word. I have changed the name of this field throughout the code and added a rename field command to the upgrade script but it appears that people using the version of MySQL that has it as a reserved word cannot execute the upgrade script. I'm guessing because it will not allow the old name in the "ALTER TABLE" command?
The error that occurs is on this command:
ALTER TABLE mdl_questionnaire_response_rank CHANGE rank rankvalue BIGINT(11) NOT NULL
So, how do I rename the field?
The upgrade script is as follows:
$table = new xmldb_table('questionnaire_response_rank');
$rankfieldname = $DB->get_manager()->generator->getEncQuoted('rank');
$field = new xmldb_field($rankfieldname, XMLDB_TYPE_INTEGER, '11', null, XMLDB_NOTNULL, null, null, null, '0', 'choice_id');
if ($dbman->field_exists($table, $field)) {
$dbman->rename_field($table, $field, 'rankvalue');
}