title: Knex migration down error when trying to drop constraint and alter column
body: <p>I had, on a previous migration, a column named <code>status</code> which was <code>boolean</code>. In this migration, I altered it to integer and created a reference to the <code>meetings_statuses</code>.</p>
  <p>This is the migration:</p>
  <pre><code>exports.up = (knex) =&gt; {
    return knex.schema.alterTable(&quot;meetings&quot;, (table) =&gt; {
      table.integer(&quot;status&quot;).notNullable().unsigned().alter();
  
      table
        .foreign(&quot;status&quot;)
        .references(&quot;id&quot;)
        .inTable(&quot;meetings_statuses&quot;)
        .onDelete(&quot;RESTRICT&quot;);
    });
  };
  
  exports.down = (knex) =&gt; {
    return knex.schema.debug().alterTable(&quot;meetings&quot;, (table) =&gt; {
      table.dropForeign(&quot;status&quot;);
  
      table.boolean(&quot;status&quot;).notNullable().defaultTo(true).alter();
    });
  };
  </code></pre>
  <p>When migrating down I want to go back to the old column type and drop the foreign relationship. However, when I do it I get the error:</p>
  <blockquote>
  <pre><code>migration file &quot;20210205004841_alter_meetings_table.js&quot; failed
  migration failed with error: alter table &quot;meetings&quot; alter column &quot;status&quot; type boolean using (&quot;status&quot;::boolean) - foreign key
  </code></pre>
  </blockquote>
  <p>The debug shows me this:</p>
  <pre><code>[
    {
      sql: 'alter table &quot;meetings&quot; alter column &quot;status&quot; drop default',
      bindings: []
    },
    {
      sql: 'alter table &quot;meetings&quot; alter column &quot;status&quot; drop not null',
      bindings: []
    },
    {
      sql: 'alter table &quot;meetings&quot; alter column &quot;status&quot; type boolean using (&quot;status&quot;::boolean)',
      bindings: []
    },
    {
      sql: `alter table &quot;meetings&quot; alter column &quot;status&quot; set default '1'`,
      bindings: []
    },
    {
      sql: 'alter table &quot;meetings&quot; alter column &quot;status&quot; set not null',
      bindings: []
    },
    {
      sql: 'alter table &quot;meetings&quot; drop constraint &quot;meetings_status_foreign&quot;',
      bindings: []
    }
  ]
  </code></pre>
  <p>What I'm thinking is that, for some reason, Knex is trying to change the column first instead of dropping the constraint, causing the error, but I couldn't find any solution.</p>
  <p>Can anyone help me?</p>