<p><a href="https://github.com/dbsrgits/sql-translator/blob/master/lib/SQL/Translator/Diff.pm#L237">https://github.com/dbsrgits/sql-translator/blob/master/lib/SQL/Translator/Diff.pm#L237</a> is where the madness starts. If a renamed table also has a renamed field then this is the wrong way round since field and possible constraints (pk/unique/...) must be renamed before the table or else you end up with nonsense like:</p>
<pre><code>ALTER TABLE foos RENAME TO trees;
ALTER TABLE foos DROP CONSTRAINT foos_pkey;
</code></pre>
<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/issues/40#issuecomment-51081691">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/302594__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyMjc4ODIzNSwiZGF0YSI6eyJpZCI6MzY1ODc4MjJ9fQ==--f83fa9fbda241311e3bb9445aacd876af7ba27c8.gif" width="1" /></p>