title: laravel errno 150 foreign key constraint is incorrectly formed
body: <p>Can anybody help me to solve this problem?</p>
  <p>There are 3 tables with 2 foreign keys:</p>
  <pre><code>Schema::create('users', function (Blueprint $table) {
      $table-&gt;increments('id');
      $table-&gt;string('name');
      $table-&gt;string('email')-&gt;unique();
      $table-&gt;string('password');
      $table-&gt;rememberToken();
      $table-&gt;timestamps();
  });
  
  Schema::create('firms', function (Blueprint $table) {
      $table-&gt;increments('id');
      $table-&gt;string('title')-&gt;nullable();
      $table-&gt;integer('user_id')-&gt;unsigned()-&gt;nullable();
      $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users');
      $table-&gt;timestamps();
  });
  
  Schema::create('jobs', function (Blueprint $table) {
      $table-&gt;increments('id');
      $table-&gt;string('title')-&gt;nullable();
      $table-&gt;integer('firm_id')-&gt;unsigned()-&gt;nullable();
      $table-&gt;foreign('firm_id')-&gt;references('id')-&gt;on('firms');
      $table-&gt;timestamps();
  });
                      
  </code></pre>
  <p><strong>Error after running migration:</strong></p>
  <pre><code>[Illuminate\Database\QueryException]
    SQLSTATE[HY000]: General error: 1005 Can't create table `job`.`#sql-5fc_a1`
     (errno: 150 &quot;Foreign key constraint is incorrectly formed&quot;) (SQL: alter ta
    ble `firms` add constraint `firms_user_id_foreign` foreign key (`user_id`)
    references `users` (`id`))
  
    [PDOException]
    SQLSTATE[HY000]: General error: 1005 Can't create table `job`.`#sql-5fc_a1`
     (errno: 150 &quot;Foreign key constraint is incorrectly formed&quot;)
  </code></pre>