[Dbix-class] Deployment seems to destroy CHARACTER SET settings on MySQL tables

Matija Grabnar matija at serverflow.com
Sun Aug 10 14:32:53 GMT 2014


I am developing a Catalyst application that uses DBIx::Class. I thought 
I would do things right and use DBIx::Class::DeploymentHandler right 
from the start.
I was able to get it to deploy and upgrade my tables very nicely.
However, I have run into a show stopper now:

The character set settings of tables and strings are not preserved. That 
means that if I declare a table like this:

create table graph_category (
id serial primary key,
category varchar(190) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
unique index i_graph_category_category(category)
) engine=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

and then do
dbicdump -o dump_directory=./lib \
            -o debug=1 \
            MyDB \
            'dbi:mysql:dbname=mydb' \
            someusername \
            notthepassword


And then a script containing
  my $dh = DBIx::Class::DeploymentHandler->new(
      {
          schema              => $schema,
          script_directory    => "$FindBin::Bin/../dbicdh",
          databases           => 'MySQL',
          sql_translator_args => { add_drop_table => 1 },
          force_overwrite     => $force_overwrite,
      }
     );

$dh->prepare_install;
$dh->install;

The table in the database will become:

CREATE TABLE `graph_category` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
   `category` varchar(190) DEFAULT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `i_graph_category_category` (`category`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

In other words, all the character set info has disappeared. Since the 
requirements specify a lot of UTF8 work, I find that quite distressing. 
And in production, I'm afraid it could lead to data corruption.

Does anybody know of a way to avoid this problem (short of discarding 
DeploymentHandler altogether)?



More information about the DBIx-Class mailing list