Inconsistent table encoding?
I've got a database that I've developed over time using Phinx. One issue I discovered along the way was that the tables were formatted using the latin1 character set and cp1252 West European encoding. So while consolidating Phinx migrations, I started explicitly setting the encoding as seen below:
<?php
declare(strict_types=1);
use Migrations\AbstractMigration;
class CreateCarts extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
* @return void
*/
public function change()
{
$table = $this->table('carts', [
'encoding' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
])
->addColumn('user_id', 'integer', [
'default' => null,
'null' => false,
])
->addColumn('cart_status', 'string', [
'default' => 'active',
'null' => false,
])
->addColumn('created', 'datetime', [
'default' => null,
'null' => false,
])
->addColumn('modified', 'datetime', [
'default' => null,
'null' => false,
])
->addColumn('cart_total', 'float', [
'default' => null,
]);
$table->create();
}
}
However, when reviewing the tables, I discovered that not all of the tables are properly encoded despite explicitly being set in the options array shown here? Some do indeed take the UTF-8 multibyte encoding and some do not.
There are no other, altering migrations any longer because I consolidated them: only one migration creates a database and it does not get altered futher in the migration process. Any idea why this would be?
You could try the --dry-run flag to see a print of all create commands that get run to see if any are missing the encoding / collation arguments?