Problems updating to Moodle 3.5 with MySQL 8.0 and mod_chat

Problems updating to Moodle 3.5 with MySQL 8.0 and mod_chat

by Debbie Unterseher -
Number of replies: 6

The following was sent from my IT person, and might be helpful to others:


We had problems updating to Moodle 3.5 using MySQL 8.0 because the word system is a reserved word.  Had to make the following changes:


Changed the 'system' to be '`system`'

    if ($oldversion < 2017111301) {
        // Rename field 'system' on table 'chat_messages' as it is a reserved word in MySQL 8+.
        $table = new xmldb_table('chat_messages');
        $field = new xmldb_field('`system`');
        if ($dbman->field_exists($table, $field)) {
            $field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'groupid');
            // Extend the execution time limit of the script to 2 hours.
            upgrade_set_timeout(7200);
            // Rename it to 'issystem'.
            $dbman->rename_field($table, $field, 'issystem');
        }

        // Rename field 'system' on table 'chat_messages_current' as it is a reserved word in MySQL 8+.
        $table = new xmldb_table('chat_messages_current');
        $field = new xmldb_field('`system`');
        if ($dbman->field_exists($table, $field)) {
            $field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'groupid');
            // Extend the execution time limit of the script to 5 minutes.
            upgrade_set_timeout(300);
            // Rename it to 'issystem'.
            $dbman->rename_field($table, $field, 'issystem');
        }

        // Savepoint reached.
        upgrade_mod_savepoint(true, 2017111301, 'chat');
    }






Attachment image.png
Average of ratings: Useful (1)
In reply to Debbie Unterseher

Re: Problems updating to Moodle 3.5 with MySQL 8.0 and mod_chat

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Debbie,
TNX for sharing your issue and solution too: when working at MDL-60793 we believed people would jump to 3.5 via 3.3 or 3.4 - by updating first to the latest 3.3.x/3.4.y available and still working w/ MySQL 5.7 and then moving to MySQL 8 being then Moodle compatible with it -, but eventually we were wrong wink.

Could you give us more details on how you moved to MySQL 8.x running what version of Moodle before upgrading?
The more the better wink: I'm going to file an issue into the Tracker, including proposing a fix compatible with all the DB supported by Moodle.

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: Problems updating to Moodle 3.5 with MySQL 8.0 and mod_chat

by Debbie Unterseher -

The following was the information that my IT person sent me:

  1. Started with Moodle version 3.2.6
  2. We did a backup of the database from the MariaDB version 5.5.56
  3. Created a new server with MySQL version 8.0.11
  4. Loaded the backup from MariaDB to MySQL
  5. Created a new server for Moodle.
  6. Used the git method to checkout the 3.5 version of moodle
  7. Used a web browser to go to the moodle site and was presented with the upgrade screen which then eventually led to the screen shot.
  8. I then used MySQL WorkBench to manually change the system column name to find the syntax that should be used.
  9. I then modified the upgrade.php in the chat module to have the accent mark around system.  This then allowed the upgrade script to run correctly.

In reply to Debbie Unterseher

Re: Problems updating to Moodle 3.5 with MySQL 8.0 and mod_chat

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

TNX Debbie!
I'll file the issue into the Tracker.

Moodle addressed all the known issues - both in the modules code and in the unit tests testing some edge cases in the DB API - around MySQL 8 since 3.3.7/3.4.4/3.5.1, even if MDL-59098 is still open for some feedback.

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: Problems updating to Moodle 3.5 with MySQL 8.0 and mod_chat

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hello Everyone,
for the record, when MDL-63319 will land in the main stream, the hack above won't be required anymore.

Vote for it! big grin

TIA,
Matteo

In reply to Debbie Unterseher

Re: Problems updating to Moodle 3.5 with MySQL 8.0 and mod_chat

by Jörg Schäfer -

many thanks for your solution. We have just successfully upgraded to mysql 8.0.3 an moodle 3.5.1 after reading your contribution.