title: Laravel migration won't reference second foreign key
body: <p>I am trying to reference the id of a product on two tables (a categories and a brands table).  </p>
  
  <pre><code>public function up()
  {
          Schema::create('products', function($table)
          {
                  $table-&gt;increments('id');
                  $table-&gt;integer('category_id')-&gt;unsigned();
                  $table-&gt;integer('brand_id')-&gt;unsigned();
                  $table-&gt;string('title');
                  $table-&gt;text('description');
                  $table-&gt;decimal('price', 6, 2);
                  $table-&gt;boolean('availability')-&gt;default(1);
                  $table-&gt;string('image');
                  $table-&gt;timestamps();
          });
  
          Schema::table('products', function($table){
                  $table-&gt;foreign('category_id')-&gt;references('id')-&gt;on('categories');
                  $table-&gt;foreign('brand_id')-&gt;references('id')-&gt;on('brands');
          });
  }
  </code></pre>
  
  <p>But I get the following errors: </p>
  
  <pre><code>[Illuminate\Database\QueryException]
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL
  : alter table `products` add constraint products_brand_id_foreign foreign k
  ey (`brand_id`) references `brands` (`id`))
  
  
  [PDOException]
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
  </code></pre>
  
  <p>Which is the correct way to do this? </p>
  
  <p><strong>Update</strong> </p>
  
  <p>Migration public function up for the brands table</p>
  
  <pre><code>public function up()
  {
          Schema::create('brands', function($table){
                  $table-&gt;increments('id');
                  $table-&gt;string('name');
                  $table-&gt;timestamps();
          });
  }
  </code></pre>
  
  <p><strong>Solution</strong></p>
  
  <p>Finally, the error was on the naming of the migration. Due to the fact that brands table was the most recent table I had to changed its name from: <code>2014_12_12_164325_create_brands_table</code> to this <code>2014_10_12_164325_create_brands_table</code> and the tables were migrated successfully. </p>