<p>In <a href="https://github.com/dbsrgits/sql-translator/pull/56#discussion_r33204957">lib/SQL/Translator/Producer/MySQL.pm</a>:</p>
<pre style='color:#555'>> @@ -457,11 +457,17 @@ sub create_table
> #
> my @constraint_defs;
> my @constraints = $table->get_constraints;
> +
> + # Get the primary key, if there is one. No need to create an index for an
> + # FK that is also the PK. It may be a multi-field key, so generate a
> + # suitable string for comparison.
> + my $pk = join "\0", map $_->fields, grep $_->type eq PRIMARY_KEY, @constraints;
</pre>
<p>Here you're joining all the fields in the primary key, but below you're testing that against the first field in the foreign key, so this can't work at all for composite primary keys.</p>
<p>I don't if the current handling is actually correct for compound indexes and foreign keys, but either way, I think primary keys should be handled the same as normal indexes (i.e. just add each field to <code>%indexed_fields</code>).</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/dbsrgits/sql-translator/pull/56/files#r33204957">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AASeAscfkJWhsDLHk1x23JSRQUZWX2P7ks5oWyg9gaJpZM4ElEZI.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/dbsrgits/sql-translator/pull/56/files#r33204957"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>