title: Laravel changing foreign key constraint
body: <p>I have a table with an already created foreign key constraint:</p>
  
  <pre><code>$table-&gt;foreign('cms_id')-&gt;references('id')-&gt;on('inventories');
  </code></pre>
  
  <p>I need to change this foreign key so that it references <code>remote_id</code> and not <code>id</code> column in the <code>inventories</code> table.</p>
  
  <p>I have tried that by doing this:</p>
  
  <pre><code>    public function up()
      {
          Schema::table('contents', function (Blueprint $table) {
              $table-&gt;dropForeign('contents_cms_id_foreign');
              $table-&gt;foreign('cms_id')-&gt;references('remote_id')-&gt;on('inventories');
          });
      }
  </code></pre>
  
  <p>But, I get:</p>
  
  <blockquote>
    <p>[Illuminate\Database\QueryException]<br>
    SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
    (SQL     : alter table <code>contents</code> add constraint
    <code>contents_cms_id_foreign</code> foreign k     ey (<code>cms_id</code>) references
    <code>inventories</code> (<code>remote_id</code>))</p>
    
    <p>[PDOException]<br>
    SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint</p>
  </blockquote>