title: Laravel: Migration not working due to errno: 150 "Foreign key constraint is incorrectly formed" error
body: <p>I'm trying to execute a migration of two seperate tables including relationships:</p>
  
  <p><strong>First table:</strong></p>
  
  <pre><code>public function up()
  {
  
  Schema::create('Gerecht', function (Blueprint $table) {
  $table-&gt;increments('Gerechtcode');
  $table-&gt;string('Gerecht', 20);
  
  $table-&gt;foreign('Gerechtcode')-&gt;references('Gerechtcode')-&gt;on('Subgerecht');
  });
  
  }
  </code></pre>
  
  <p><strong>Second table:</strong></p>
  
  <pre><code>public function up()
  {
  
  Schema::create('Subgerecht', function (Blueprint $table) {
  $table-&gt;increments('SubgerechtCode');
  $table-&gt;string('Gerechtcode',3 );
  $table-&gt;string('Subgerecht', 25);
  
  $table-&gt;foreign('Gerechtcode')-&gt;references('Gerechtcode')-&gt;on('Gerecht');
  });
  
  }
  </code></pre>
  
  <p>But it gives me an error as followed: </p>
  
  <pre><code>   Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 1005 Can't create table `excellent-taste-db`.`#sql-59c_7d` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table `Gerecht` add constraint `gerecht_gerechtcode_foreign` foreign key (`Gerechtcode`) references `Subgerecht` (`Gerechtcode`))
  </code></pre>