title: General error: 1215 Cannot add foreign key constraint - laravel migrations
body: <p>I'm trying to add a couple of foreign keys to a pivot table, like thus:-</p>
  <pre><code>public function up()
      {
          Schema::create('posts', function (Blueprint $table) {
              $table-&gt;bigIncrements('id');
              $table-&gt;unsignedInteger('user_id');
              $table-&gt;string('author');
              $table-&gt;string('title');
              $table-&gt;longText('content');
              $table-&gt;timestamps();
              $table-&gt;engine = 'InnoDB';
          });
      }
  </code></pre>
  <pre><code>public function up()
      {
          Schema::create('tags', function (Blueprint $table) {
              $table-&gt;bigIncrements('id');
              $table-&gt;string('name');
              $table-&gt;timestamps();
              $table-&gt;engine = 'InnoDB';
          });
      }
  </code></pre>
  <pre><code>public function up()
      {
          Schema::create('post_tag', function (Blueprint $table) {
              $table-&gt;primary(['post_id', 'tag_id']);
              $table-&gt;bigInteger('post_id');
              $table-&gt;bigInteger('tag_id');
              // $table-&gt;foreign('post_id')-&gt;references('id')-&gt;on('posts')-&gt;onDelete('cascade');
              // $table-&gt;foreign('tag_id')-&gt;references('id')-&gt;on('tags')-&gt;onDelete('cascade');
              $table-&gt;timestamps();
              $table-&gt;engine = 'InnoDB';
          });
  
          Schema::table('post_tag', function($table) {
              $table-&gt;foreign('post_id')-&gt;references('id')-&gt;on('posts')-&gt;onDelete('cascade');
              $table-&gt;foreign('tag_id')-&gt;references('id')-&gt;on('tags')-&gt;onDelete('cascade');
          }); 
          
      }
  </code></pre>
  <p>I run the migrations and receive an error like thus:-</p>
  <pre><code>In Connection.php line 692:
  
    SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL
    : alter table `post_tag` add constraint `post_tag_post_id_foreign` foreign
    key (`post_id`) references `posts` (`id`) on delete cascade)
  
  
  In Connection.php line 485:
  
    SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
  
  </code></pre>
  <p>Looking around the net and I'm led to believe its an integrity violation between primary/foreign key datatypes. Like, a foreign key with an integer data type can't reference a primary key whose type is of bigInt. But, in my migration, I'm ensuring the types are the same. Alas, no matter, I still get the error and my migrations fail to compile?</p>
  <p>Help</p>