<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Lianna, thank you!<br>
      <br>
       I put the module you wrote in my lib directory, and I modified
      the call I make to dbicdump to <br>
      include the loader class:<br>
      <br>
      dbicdump -I ./lib <br>
                 -o dump_directory=./lib \<br>
                 -o debug=1 \<br>
                 -o
      loader_class='MyApp::Schema::Loader::DBI::mysql::ExtraColumnInfo'
      \<br>
                 MyDB \<br>
                 'dbi:mysql:dbname=mydb' \<br>
                 someusername \<br>
                 notthepassword<br>
      <br>
      But it still doesn't record the character set details into the
      Result files that it generates (or anywhere else that I can find).
      And that means that the install/upgrade scripts also don't get the
      info.<br>
      <br>
      I am using DBIx::Class::Schema::Loader 0.7039, do I need a later
      version? Or am I missing something else?<br>
      <br>
      <br>
      Best regards,<br>
                       Matija Grabnar<br>
      <br>
      On 08/12/2014 04:41 PM, Lianna Eeftinck wrote:<br>
    </div>
    <blockquote
cite="mid:CAMWrOUoM5NLpcg-cw_gbzo+y2cU4iovJDNetp=GamCupBJiTmQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif;font-size:small"><font><span
              style="font-family:courier new,monospace">package
              MyApp::Schema::Loader::DBI::mysql::ExtraColumnInfo;<br>
              use strict;<br>
              use warnings;<br>
              use base 'DBIx::Class::Schema::Loader::DBI::mysql';<br>
              use mro 'c3';<br>
              <br>
              my $mysql_text_types = qr/^(?: var(?:char)? |
              char(?:acter)? | (?:tiny|medium|long)?text )$/msxi;<br>
              <br>
              sub new {<br>
                  return shift-&gt;next::method( @_ );<br>
              }<br>
              <br>
              sub _extra_column_info {<br>
                  my ( $self, $table, $col, $info, $dbi_info ) = @_;<br>
              <br>
                  my $extra_info = $self-&gt;next::method( $table, $col,
              $info, $dbi_info );<br>
              <br>
                  if ( $info-&gt;{data_type} =~ /$mysql_text_types/msxi
              ) {<br>
                      my ( $character_set_name, $collation_name ) = eval
              {<br>
                          $self-&gt;dbh-&gt;selectrow_array( qq{<br>
                             SELECT character_set_name, collation_name<br>
                             FROM information_schema.columns<br>
                             WHERE table_name = ? AND lower(column_name)
              = ?<br>
                          }, {}, $table-&gt;name, lc( $col ) );<br>
                      };<br>
              <br>
                      if ( my $has_information_schema = not $@ ) {<br>
                          $extra_info-&gt;{ extra }{ mysql_collate } =
              $collation_name;<br>
                          $extra_info-&gt;{ extra }{ mysql_charset } =
              $character_set_name;<br>
                      }<br>
                  }<br>
              <br>
                  return $extra_info;<br>
              }<br>
              <br>
              1;</span></font><br>
          <br>
          <br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif;font-size:small">And
          include it in the schema loader options too:<br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif;font-size:small">
          <br>
          <span style="font-family:courier new,monospace">loader_class
            =&gt; 'MyApp::Schema::Loader::DBI::mysql::ExtraColumnInfo'</span><br>
          <br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif;font-size:small">
          It's actually reading the database where this information gets
          lost, it's never stored in the YAML generated by
          DBIx::Schema::Loader, so it won't be output properly either
          until it is added.<br>
          <br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif;font-size:small">
          -- Lianna<br>
        </div>
        <div class="gmail_default"
          style="font-family:arial,helvetica,sans-serif;font-size:small"><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On 10 August 2014 15:32, Matija Grabnar
          <span dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:matija@serverflow.com" target="_blank">matija@serverflow.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div class="im HOEnZb">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.<br>
              I was able to get it to deploy and upgrade my tables very
              nicely.<br>
              However, I have run into a show stopper now:<br>
              <br>
              The character set settings of tables and strings are not
              preserved. That means that if I declare a table like this:<br>
              <br>
              create table graph_category (<br>
              id serial primary key,<br>
              category varchar(190) CHARACTER SET utf8mb4 COLLATE
              utf8mb4_unicode_ci,<br>
              unique index i_graph_category_category(category)<br>
              ) engine=InnoDB DEFAULT CHARSET=utf8mb4
              COLLATE=utf8mb4_unicode_ci;<br>
              <br>
            </div>
            <div class="im HOEnZb">
              and then do<br>
              dbicdump -o dump_directory=./lib \<br>
                         -o debug=1 \<br>
                         MyDB \<br>
                         'dbi:mysql:dbname=mydb' \<br>
                         someusername \<br>
                         notthepassword<br>
              <br>
              <br>
              And then a script containing<br>
               my $dh = DBIx::Class::DeploymentHandler-&gt;new(<br>
                   {<br>
                       schema              =&gt; $schema,<br>
                       script_directory    =&gt;
              "$FindBin::Bin/../dbicdh",<br>
                       databases           =&gt; 'MySQL',<br>
                       sql_translator_args =&gt; { add_drop_table =&gt;
              1 },<br>
                       force_overwrite     =&gt; $force_overwrite,<br>
                   }<br>
                  );<br>
              <br>
              $dh-&gt;prepare_install;<br>
              $dh-&gt;install;<br>
              <br>
              The table in the database will become:<br>
              <br>
            </div>
            <div class="HOEnZb">
              <div class="h5">
                CREATE TABLE `graph_category` (<br>
                  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,<br>
                  `category` varchar(190) DEFAULT NULL,<br>
                  PRIMARY KEY (`id`),<br>
                  UNIQUE KEY `i_graph_category_category` (`category`)<br>
                ) ENGINE=InnoDB DEFAULT CHARSET=latin1<br>
                <br>
                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.<br>
                <br>
                Does anybody know of a way to avoid this problem (short
                of discarding DeploymentHandler altogether)?<br>
                <br>
                _______________________________________________<br>
                List: <a moz-do-not-send="true"
                  href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class"
                  target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a><br>
                IRC: <a moz-do-not-send="true"
                  href="http://irc.perl.org#dbix-class" target="_blank">irc.perl.org#dbix-class</a><br>
                SVN: <a moz-do-not-send="true"
                  href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/"
                  target="_blank">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a><br>
                Searchable Archive: <a moz-do-not-send="true"
                  href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk"
                  target="_blank">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a><br>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
List: <a class="moz-txt-link-freetext" href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a>
IRC: irc.perl.org#dbix-class
SVN: <a class="moz-txt-link-freetext" href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a>
Searchable Archive: <a class="moz-txt-link-freetext" href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a></pre>
    </blockquote>
    <br>
  </body>
</html>