title: Migration: Cannot add foreign key constraint
body: <p>I'm trying to create foreign keys in Laravel however when I migrate my table using <code>artisan</code> i am thrown the following error:</p>
  
  <pre><code>[Illuminate\Database\QueryException]
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL
  : alter table `priorities` add constraint priorities_user_id_foreign foreign 
  key (`user_id`) references `users` (`id`))     
  </code></pre>
  
  <p>My migration code is as so:    </p>
  
  <p>priorities migration file</p>
  
  <pre><code>public function up()
  {
      //
      Schema::create('priorities', function($table) {
          $table-&gt;increments('id', true);
          $table-&gt;integer('user_id');
          $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users');
          $table-&gt;string('priority_name');
          $table-&gt;smallInteger('rank');
          $table-&gt;text('class');
          $table-&gt;timestamps('timecreated');
      });
  }
  
  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down()
  {
      //
      Schema::drop('priorities');
  }
  </code></pre>
  
  <p>users migration file </p>
  
  <pre><code>public function up()
  {
      //
      Schema::table('users', function($table)
      {
      $table-&gt;create();
      $table-&gt;increments('id');
      $table-&gt;string('email');
      $table-&gt;string('first_name');
      $table-&gt;string('password');
      $table-&gt;string('email_code');
      $table-&gt;string('time_created');
      $table-&gt;string('ip');
      $table-&gt;string('confirmed');
      $table-&gt;string('user_role');
      $table-&gt;string('salt');
      $table-&gt;string('last_login');
  
      $table-&gt;timestamps();
      });
  }
  
  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down()
  {
      //
          Schemea::drop('users');
  }
  </code></pre>
  
  <p>Any ideas as to what I've done wrong, I want to get this right now, as I've got a lot of tables I need to create e.g. Users, Clients, Projects, Tasks, Statuses, Priorities, Types, Teams. Ideally I want to create tables which hold this data with the foreign keys, i..e <code>clients_project</code> and <code>project_tasks</code> etc. </p>
  
  <p>Hope someone can help me to get started. </p>