title: Can't create foreign key with laravel database migration
body: <p>I have a problem with my Laravel migrations :(</p>
  <p>when i'm running php artisan migrate, it stops on a foreign key.</p>
  <p>first migration</p>
  <pre><code>/**
   * Run the migrations.
   *
   * @return void
   */
  public function up()
  {
      Schema::enableForeignKeyConstraints();
      Schema::create('fichefrais', function (Blueprint $table) {
          $table-&gt;char('idVisiteur', 4);
          $table-&gt;foreign('idVisiteur')-&gt;references('id')-&gt;on('visiteur');
          $table-&gt;char('mois',6);
          $table-&gt;primary(['idVisiteur', 'mois']);
          $table-&gt;integer('nbJustificatifs');
          $table-&gt;decimal('montantValide', 10, 2);
          $table-&gt;date('dateModif');
          $table-&gt;char('idEtat', 2);
          $table-&gt;foreign('idEtat')-&gt;references('id')-&gt;on('etat');
      });
  }
  
  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down()
  {
      Schema::dropIfExists('fichefrais');
  }
  </code></pre>
  <p>and the second</p>
  <pre><code>/**
   * Run the migrations.
   *
   * @return void
   */
  public function up()
  {
      Schema::enableForeignKeyConstraints();
      Schema::create('lignefraishorsforfait', function (Blueprint $table) {
          $table-&gt;integer('id');
          $table-&gt;primary('id');
          $table-&gt;char('idVisiteur', 4);
          $table-&gt;char('mois',6);
          $table-&gt;foreign('idVisiteur')-&gt;references('idVisiteur')-&gt;on('fichefrais');
          $table-&gt;foreign('mois')-&gt;references('mois')-&gt;on('fichefrais');
          $table-&gt;char('libelle', 100);
          $table-&gt;date('date');
          $table-&gt;decimal('montant', 10, 2);
      });
  }
  
  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down()
  {
      Schema::dropIfExists('lignefraishorsforfait');
  }
  </code></pre>
  <p>After running the command, I got this error :</p>
  <blockquote>
  <p>[Illuminate\Database\QueryException]<br />
  SQLSTATE[HY000]: General error: 1005 Can't create table
  gsb_larave.#sql-176_b9 (errno: 150 &quot;Foreign key constraint is
  incorrectly formed&quot;) (SQL: alter table lignefraishors     forfait
  add constraint lignefraishorsforfait_mois_foreign foreign key
  (mois) references fichefrais (mois) on delete cascade on update
  cascade)</p>
  <p>[PDOException]<br />
  SQLSTATE[HY000]: General error: 1005 Can't create table
  gsb_laravel.#sql-176_b9 (errno: 150 &quot;Foreign key constraint is
  incorrectly formed&quot;)</p>
  </blockquote>