I used this script to convert my D7 database to utf8mb4.. It worked fine in converting the collation, but it failed miserably in keeping the original default value, 'not null' and the comment definition.
When running the Schema module to report any DB mismatches, it reported several of the following (examples taken from the system table):
column name - differences on: not null, default
declared: array('description' => 'TODO: please describe this field!', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')
actual: array('description' => 'TODO: please describe this field!', 'type' => 'varchar', 'length' => '255', 'not null' => FALSE)
column type - differences on: not null, default
declared: array('description' => 'TODO: please describe this field!', 'type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => '')
actual: array('description' => 'TODO: please describe this field!', 'type' => 'varchar', 'length' => '12', 'not null' => FALSE)
column owner - differences on: not null, default
declared: array('description' => 'TODO: please describe this field!', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '')
actual: array('description' => 'TODO: please describe this field!', 'type' => 'varchar', 'length' => '255', 'not null' => FALSE)
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 2781545-utf8mb4_convert-schema_fix-7x-16.patch | 3.91 KB | nerdcore |
| #15 | 2781545-utf8mb4_convert-schema-fix-11.patch | 4.27 KB | morbiD |
| #5 | 2781545-5.patch | 1.5 KB | stefan.r |
Comments
Comment #2
stefan.r commentedHmm, that's no good -- this will need a patch, and ideally an upgrade path for anyone else with the same problem.
Comment #3
jcnventuraComment #4
jcnventuraJust noticed that the schema 'description', which gets added as a table structure comment is also gone.
Comment #5
stefan.r commentedFor now, something like this might do (very ugly though).
We'll also have to provide an upgrade path for people who have already run the script, and who don't have the option to recover from backups and run a newer version of the script. I guess we'll have to use the schema.
Problem is, they already might have inconsistent data because of other defaults/not null options :(
Comment #7
stefan.r commentedEmergency beta2 release which includes this fix: https://www.drupal.org/project/utf8mb4_convert/releases/7.x-1.0-beta2
It's very unfortunate this took 6 weeks to be found, and 2000 people downloaded "broken" versions already.
If at all possible, for now (while we don't have any upgrade path) the recommended way to go is to recover old backups, and re-run the script using beta2 or later.
Comment #8
stefan.r commentedBack to Critical. Included a mention of this issue on the project page as well.
Comment #9
karlsheaWARNING: obviously(!), don't run this without backups or testing
I ran this with the Schema module installed to fix my field definitions:
Comment #10
morbiD commentedThe code in #9 does seem to restore the correct
NOT NULLandDEFAULTsettings, but not the descriptions.According to Jane_wu's comments on the
drupal_get_schema()documentation, it doesn't actually return any descriptions:Comment #11
morbiD commentedFurther to my previous comment, I replaced the call to
drupal_get_schema()with some relevant code ripped fromdrupal_get_complete_schema()and then addedFALSEto the_drupal_schema_initialize()call so that it doesn't remove the descriptions.This seems to work better:
Comment #12
stefan.r commentedCan we turn this into a patch so that we can run this by doing "drush utf8mb4-convert-fix"?
Comment #13
morbiD commentedI'm not familiar with drush authoring but I'll have a look at the documentation on drush.org and see if I can provide a patch.
To turn this into a drush command, do we need to get rid of the dependency on
schema_dbobject()->inspect()from schema.module?Comment #14
stefan.r commentedI'm OK with keeping the dependency -- just fail with a drush_print() telling people to install the schema module if it's not installed.
Comment #15
morbiD commentedOk, here's my first attempt at a patch to add the new command - I hope it's suitable.
Would it have been preferable to add another function to the
DrupalCharsetConverterclass and use$this->connection->query()syntax?Anyway, I've only tested it on a single server running a single site, but it seems to do the trick.
Comment #16
nerdcore commentedRe-roll of previous patch without email headers
Comment #18
bkosborneShould this be closed if it's been committed?
Comment #19
jcnventura@bkosborne. Yes. Let's mark it fixed, and let d.o close it in 2 weeks.