Collation Fixer
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Downloads
Component created
Component changed
Component body
A 'runtime' requirements checker (admin/reports/status
) for checking all database tables have the right database collation (probably very MySQL centric).
Offers the ability to fix tables with wrong database collation.
The collation is either specified in your database settings or in hook_schema() or hook_schema_alter().
This can be useful when developing non-english sites.
Example of specifying in database settings in settings.php (will affect all tables - it's probably better to do it in hook_schema() or hook_schema_alter()):
$databases = array(
'default' => array(
'default' => array(
'database' => 'my-db',
'username' => 'my-user',
'password' => 'my-password',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_danish_ci',
),
),
);
See also Multi-byte UTF-8 support in Drupal 7 and UTF8MB4 Convert.
Example of specifying via hook_schema_alter():
/**
* Implements hook_schema_alter().
*/
function my_module_schema_alter(&$schema) {
$schema['field_data_title_field']['collation'] = 'utf8mb4_danish_ci';
}
If you (as a developer) changes the collation of an existing table you will probably want to fix the table right away in a hook_update_N():
/**
* Fix collation of {my_table}.
*/
function my_module_update_7101(&$sandbox) {
collation_fixer_fix_collation('my_table');
}