title: Laravel migration can't add foreign key
body: <p>I'm trying to write a laravel database migration but I'm getting the following error about a foreign key: </p>
  
  <pre><code>  [Illuminate\Database\QueryException]                                                                                                                                                                                                                    
    SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'category_id' doesn't exist in table (SQL: alter table `subcategories` add constraint subcategories_category_id_foreign foreign key (`category_id`) references `categories` (`id`))  
  
  
  
    [PDOException]                                                                                           
    SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'category_id' doesn't exist in table 
  </code></pre>
  
  <p>The <code>categories</code> and <code>subcategories</code> tables do get created but the foreign key doesn't. Here's my migration:</p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Database\Migrations\Migration;
  
  class CreateCategoryTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('categories', function ($table) {
              $table-&gt;increments('id')-&gt;unsigned();
              $table-&gt;string('name')-&gt;unique();
          });
  
          Schema::create('subcategories', function ($table) {
              $table-&gt;increments('id')-&gt;unsigned();
              $table-&gt;foreign('category_id')-&gt;references('id')-&gt;on('categories');
              $table-&gt;string('name')-&gt;unique();
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::drop('categories');
          Schema::drop('subcategories');
      }
  }
  </code></pre>
  
  <p>Any ideas? Thanks!</p>