Please can someone explain UTF8 migration to me?

Please can someone explain UTF8 migration to me?

Tim Hunt - દ્વારા
Number of replies: 6
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I thought that UTF8 migration was just something we had to worry about when people upgraded from Moodle 1.5 to 1.6.

However, last night I checked in a change to the quiz module in 1.7dev that created a new table, and this morning I find that someone has kindly checked in some corresponging changes to the migrate2utf8.php and migrate2utf8.xml file.

Why is this necessary? If it is, I'll be sure to do this myself in all future database changes.

It seems to have taken 48 lines of PHP and 9 lines of XML just to say 'This table has one text column that needs to be converted'. If that is typical, doing this for all future database changes is going to be a complete pain in the neck.
In reply to Tim Hunt

Re: Please can someone explain UTF8 migration to me?

Martin Dougiamas - દ્વારા
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
a) We have to cope with 1.5 -> 1.7 upgrades

b) We need to detail exactly how to convert that text field, because it could be in any language and the language is not stored with the text.

I think we'll not maintain these further after 1.7 or something though. We'll just have to change the upgrade to refuse to run PRE1.6 -> POST 1.7, and require a two step upgrade (once to 1.7, and once to the next version).
In reply to Martin Dougiamas

Re: Please can someone explain UTF8 migration to me?

Tim Hunt - દ્વારા
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
OK, but if a new table is added in 1.7, how can it end up containing non-UTF-8 data?

If that table can never contain old data, why do we need to write conversion code for it?
In reply to Tim Hunt

Re: Please can someone explain UTF8 migration to me?

Martin Dougiamas - દ્વારા
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
The tables are added before the UTF migration, so they'll be added under the old database character set (and need to be converted).

You're right the conversion of *data* is probably not necessary (though I have a nagging feeling there was some case someone mentioned, ask Eloy on MDL-6326) but I guess it's just there for completeness.
In reply to Martin Dougiamas

Re: Please can someone explain UTF8 migration to me?

Tim Hunt - દ્વારા
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Right, well the main reason for me asking is that some of my other changes have added text-type database columns to some existing tables.

Do I need to remember which columns they were, and make sure they are converted too?
In reply to Tim Hunt

Re: Please can someone explain UTF8 migration to me?

Eloy Lafuente (stronk7) - દ્વારા
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Tim,

yep, all the textual columns created under Moodle 1.7 must have their correspondence in the UTF-8 migration stuff. Absolutely! Required changes can go from simply editing the migration xml files to add the new field (if field contents are simply tokens) to a more complete solution (like the one implemented today by Yu with the feedback text).

All those migration to UTF-8 stuff will be out from HEAD once MOODLE_17_STABLE was released and future Moodle releases (after 1.7) will require Unicode DBs to work (I've filled Bug 6332 about that some minutes ago).

Ciao સ્મીત