All tables should be created as MyISAM and "utf8_general_ci" collation instead of InnoDB and "utf8_unicode_ci". This works fine for all tables except for "user_groups" table because the options are not inherited. As a result the schema is not valid, because foreign keys cannot be created over 2 different collations.
To fix this, I modified class "\Doctrine\ORM\Tools\SchemaTool", function "gatherRelationsSql($class, $table, $schema, &$addedFks, &$blacklistedFks)" and added the following lines in the MANY_TO_MANY block:
if (isset($foreignClass->table['options'])) {
foreach ($foreignClass->table['options'] as $key => $val) {
$theJoinTable->addOption($key, $val);
}
}
Now, it works as I want. The new table is created with the right collation and engine and the foreign keys are created correct. Could you please implement this fix?
Please also have a look at DDC-972 where MyISAM support was added. The problem was already mentioned there in the last 4 comments, so it exists at least since 2012.
Jira issue originally created by user eschultz:
I'm working with Symfony 2.6 and Doctrine (MySQL), but the error is in the Doctrine 2 ORM.
I have specified a ManyToMany relation like so:
All tables should be created as MyISAM and "utf8_general_ci" collation instead of InnoDB and "utf8_unicode_ci". This works fine for all tables except for "user_groups" table because the options are not inherited. As a result the schema is not valid, because foreign keys cannot be created over 2 different collations.
To fix this, I modified class "\Doctrine\ORM\Tools\SchemaTool", function "gatherRelationsSql($class, $table, $schema, &$addedFks, &$blacklistedFks)" and added the following lines in the MANY_TO_MANY block:
Now, it works as I want. The new table is created with the right collation and engine and the foreign keys are created correct. Could you please implement this fix?