title: Laravel 5.1 - General error: 1005 Can't create table (mysql)
body: <p>I'm using laravel to migrate some data, but i'm having this message below:</p>
  
  <pre><code>[Illuminate\Database\QueryException]                                                                                                                                                                
    SQLSTATE[HY000]: General error: 1005 Can't create table 'heinz.#sql-1e83_8' (errno: 150) (SQL: alter table `funcionarios` add constraint funcionarios_supervisor_id_foreign foreign key (`supervis  
    or_id`) references `funcionarios` (`id`))  
  </code></pre>
  
  <p>I tried a lot of thing, but didn't work.</p>
  
  <p>Here is the code of the migration file. (the relevant part).</p>
  
  <pre><code>Schema::create('funcionarios', function (Blueprint $table) {
  
  //            $table-&gt;engine = 'InnoDB';
  
              $table-&gt;increments('id');
              $table-&gt;string('nome', 60);
              $table-&gt;integer('matricula')-&gt;unsigned()-&gt;unique();
              $table-&gt;bigInteger('pis_pasep')-&gt;unsigned()-&gt;nullable();
              $table-&gt;date('data_admissao')-&gt;nullable();
              $table-&gt;date('data_demissao')-&gt;nullable()-&gt;default(null);
              $table-&gt;date('data_nascimento')-&gt;nullable();
              $table-&gt;string('apelido', 20)-&gt;nullable();
              $table-&gt;integer('supervisor_id')-&gt;nullable();
              $table-&gt;integer('coordenador_id')-&gt;nullable();
              $table-&gt;integer('gerente_id')-&gt;nullable();
              $table-&gt;integer('diretor_id')-&gt;nullable();
              $table-&gt;integer('sexo_id')-&gt;nullable();
              $table-&gt;integer('setor_id')-&gt;nullable();
              $table-&gt;integer('cargo_id');
              $table-&gt;integer('turno_id')-&gt;nullable();
              $table-&gt;timestamps();
          });
  
          Schema::table('funcionarios', function($table){
  
              $table-&gt;foreign('supervisor_id')-&gt;references('id')-&gt;on('funcionarios');
              $table-&gt;foreign('coordenador_id')-&gt;references('id')-&gt;on('funcionarios');
              $table-&gt;foreign('gerente_id')-&gt;references('id')-&gt;on('funcionarios');
              $table-&gt;foreign('diretor_id')-&gt;references('id')-&gt;on('funcionarios');
              $table-&gt;foreign('sexo_id')-&gt;references('id')-&gt;on('sexos');
              $table-&gt;foreign('setor_id')-&gt;references('id')-&gt;on('setores');
              $table-&gt;foreign('cargo_id')-&gt;references('id')-&gt;on('cargos');
              $table-&gt;foreign('turno_id')-&gt;references('id')-&gt;on('turnos');
  
          });
  </code></pre>