title: "General error: 1005 Can't create table" Using Laravel Schema Build and Foreign Keys
body: <p>Essentially, I am having the same issue as this guy, minus the table prefix. Because I have no table prefix, his fix does not work. <a href="http://forums.laravel.com/viewtopic.php?id=972" rel="noreferrer">http://forums.laravel.com/viewtopic.php?id=972</a></p>
  
  <p>I am trying to build a table using Laravel's Schema Builder like this:</p>
  
  <pre><code>Schema::create('lessons', function($table)
  {
      $table-&gt;increments('id');
      $table-&gt;string('title')-&gt;nullable();
      $table-&gt;string('summary')-&gt;nullable();
      $table-&gt;timestamps();
  });
  
  Schema::create('tutorials', function($table)
  {
      $table-&gt;increments('id');
      $table-&gt;integer('author');
      $table-&gt;integer('lesson');
      $table-&gt;string('title')-&gt;nullable();
      $table-&gt;string('summary')-&gt;nullable();
      $table-&gt;string('tagline')-&gt;nullable();
      $table-&gt;text('content')-&gt;nullable();
      $table-&gt;text('attachments')-&gt;nullable();
      $table-&gt;timestamps();
  });
  
  Schema::table('tutorials', function($table)
  {
      $table-&gt;foreign('author')-&gt;references('id')-&gt;on('users');
      $table-&gt;foreign('lesson')-&gt;references('id')-&gt;on('lessons');
  });
  </code></pre>
  
  <p>The issue is, when I run this code (in a /setup route), I get the following error:</p>
  
  <pre><code>SQLSTATE[HY000]: General error: 1005 Can't create table 'tutorials.#sql-2cff_da' (errno: 150)
  
  SQL: ALTER TABLE `tutorials` ADD CONSTRAINT tutorials_author_foreign FOREIGN KEY (`author`) REFERENCES `users` (`id`)
  
  Bindings: array (
  )
  </code></pre>
  
  <p>Based on posts around the web and the limited documentation available on how to <em>setup</em> Laravel's Eloquent relationships, I'm not sure what I'm doing wrong...</p>
  
  <p><code>users</code> already exists and it <em>does</em> have an <code>id</code> field that is <code>auto_increment</code>. I am also setting up my models with the proper relationships (<code>belongs_to</code> and <code>has_many</code>), but as far as I can tell this is not the issue-- it's the database setup. The DB <em>is</em> InnoDB.</p>
  
  <p>What exactly am I doing wrong with the foreign key?</p>