|
25 | 25 | use Migrations\Db\Action\RenameColumn; |
26 | 26 | use Migrations\Db\Action\RenameTable; |
27 | 27 | use Migrations\Db\Adapter\AdapterInterface; |
| 28 | +use Migrations\Db\Adapter\MysqlAdapter; |
28 | 29 | use Migrations\Db\Plan\Intent; |
29 | 30 | use Migrations\Db\Plan\Plan; |
30 | 31 | use Migrations\Db\Table\Column; |
@@ -637,19 +638,10 @@ public function create(): void |
637 | 638 | } |
638 | 639 |
|
639 | 640 | $adapter = $this->getAdapter(); |
640 | | - if ($adapter->getAdapterType() === 'mysql' && empty($options['collation'])) { |
641 | | - // TODO this should be a method on the MySQL adapter. |
642 | | - // It could be a hook method on the adapter? |
643 | | - $encodingRequest = 'SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME |
644 | | - FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = :dbname'; |
645 | | - |
646 | | - $connection = $adapter->getConnection(); |
647 | | - $connectionConfig = $connection->config(); |
648 | | - |
649 | | - $statement = $connection->execute($encodingRequest, ['dbname' => $connectionConfig['database']]); |
650 | | - $defaultEncoding = $statement->fetch('assoc'); |
651 | | - if (!empty($defaultEncoding['DEFAULT_COLLATION_NAME'])) { |
652 | | - $options['collation'] = $defaultEncoding['DEFAULT_COLLATION_NAME']; |
| 641 | + if ($adapter instanceof MysqlAdapter && empty($options['collation'])) { |
| 642 | + $collation = $adapter->getDefaultCollation(); |
| 643 | + if ($collation) { |
| 644 | + $options['collation'] = $collation; |
653 | 645 | } |
654 | 646 | } |
655 | 647 |
|
|
0 commit comments