title: Laravel migration syntax error or access violation 1064
body: <p>When i run migrations to create foreign key constraints I get the following error in my command prompt. I need help to overcome it as i searched a lot on internet and tried variety of things but unfortunately none has worked</p>
  
  <p>In Connection.php line 647:</p>
  
  <p>SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i
    n your SQL syntax; check the manual that corresponds to your MariaDB server
     version for the right syntax to use near ') on delete cascade' at line 1 (
    SQL: alter table <code>category_posts</code> add constraint <code>category_posts_post_id_fo
    reign</code> foreign key (<code>post_id</code>) references <code>posts</code> () on delete cascade)</p>
  
  <p>In Connection.php line 445:</p>
  
  <p>SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i
    n your SQL syntax; check the manual that corresponds to your MariaDB server
     version for the right syntax to use near ') on delete cascade' at line 1</p>
  
  <p>My migration code for foreign key constraint is as follows</p>
  
  <p>
  
  <pre><code>use Illuminate\Support\Facades\Schema;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Database\Migrations\Migration;
  
  class CreateCategoryPostsTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('category_posts', function (Blueprint $table) {
              $table-&gt;integer('category_id')-&gt;unsigned()-&gt;index();
              $table-&gt;integer('post_id')-&gt;unsigned()-&gt;index();
              $table-&gt;foreign('post_id')-&gt;referances('id')-&gt;on('posts')-&gt;onDelete('cascade');
              $table-&gt;timestamps();
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::dropIfExists('category_posts');
      }
  }
  </code></pre>
  
  <p>Kindly help me out. Thank you</p>