Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/app.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
'unsigned_primary_keys' => null, // Default false
'unsigned_ints' => null, // Default false, make sure this is aligned with the above config
'column_null_default' => null, // Default false
'default_collation' => null, // Default null (uses database collation). Set to e.g. 'utf8mb4_unicode_ci' to override.
],
];
3 changes: 1 addition & 2 deletions docs/en/writing-migrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,9 @@ In addition, the MySQL adapter supports following options:
Option Platform Description
========== ================ ===========
comment MySQL, Postgres set a text comment on the table
collation MySQL, SqlServer the default collation for a table if different than the database.
collation MySQL, SqlServer set the table collation *(defaults to database collation)*
row_format MySQL set the table row format
engine MySQL define table engine *(defaults to ``InnoDB``)*
collation MySQL define table collation *(defaults to ``utf8mb4_unicode_ci``)*
signed MySQL whether the primary key is ``signed`` *(defaults to ``false``)*
limit MySQL set the maximum length for the primary key
========== ================ ===========
Expand Down
6 changes: 5 additions & 1 deletion src/Db/Adapter/MysqlAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,13 @@ public function createTable(TableMetadata $table, array $columns = [], array $in
// This method is based on the MySQL docs here: https://dev.mysql.com/doc/refman/5.1/en/create-index.html
$defaultOptions = [
'engine' => 'InnoDB',
'collation' => 'utf8mb4_unicode_ci',
];

$collation = Configure::read('Migrations.default_collation');
if ($collation) {
$defaultOptions['collation'] = $collation;
}

$options = array_merge(
$defaultOptions,
array_intersect_key($this->getOptions(), $defaultOptions),
Expand Down