numbas / numbas-lti-provider

An LTI tool provider to run Numbas exams
https://docs.numbas.org.uk/lti/en/latest/
Other
11 stars 12 forks source link

Upgrading and MySQL utf8mb4 Changes #241

Closed lgretton closed 1 month ago

lgretton commented 2 years ago

I'm working on updating our provider installation from 2.7 to 3.1.

The upgrade process requires that the MySQL character set be changed to utf8mb4, but it's very light on detail. In my case the current database uses utf8, and changing this to utf8mb4 without changing the schema could cause data loss in some columns. I've eyeballed the database and I think it's ok to change this safely but could do with some reassurance.

I can't find a definition of the database schema anywhere within the code to see what the current version would create from scratch, which would be a useful sanity check. Is there a definition somewhere?

I guess I need to change the database character set and collation, and then work my way through all the tables individually. Can anyone explain exactly what is required?

jhoobergs commented 2 years ago

According to https://stackoverflow.com/a/59793236 a migration is be needed to change all tables / cols and some small changes to the database connection.

christianp commented 2 years ago

The schema is implicitly created based on the Django models, and then carried out by migrations. I don't think Django can produce a text schema for you without actually working on a database. That's the cost of abstraction, I suppose!

I can't remember how we did the upgrade. I think @georgestagg just did it and I can't find any notes about it. It looks like you'd just have to work through all the tables and columns, changing the character set manually, like the linked post by Mathias Bynens says.

Or, if you have enough disk space and time, you could dump the data with python manage.py dumpdata and load it into a new database with the right character set.