title: Laravel Integrity constraint violation on db migration
body: <pre><code>SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or update a parent row: a foreign key constraint fails (SQL: drop table `users`)
  </code></pre>
  
  <p>I know this has been answered several times, but still i cant figure our whats wrong with my migration.</p>
  
  <p><strong>First i call the partner migration</strong></p>
  
  <pre><code>public function up()
  {
      Schema::create('partners', function (Blueprint $table) {
          $table-&gt;engine = 'InnoDB';
          $table-&gt;increments('id');
          $table-&gt;integer('admin_id')-&gt;unsigned();
          $table-&gt;string('company_name', 50);
          ...
  }
  public function down()
  {
      Schema::drop('partners');
  }
  </code></pre>
  
  <p><strong>Then i call the Users migration</strong></p>
  
  <pre><code>public function up()
  {
      Schema::create('users', function (Blueprint $table) {
          $table-&gt;engine = 'InnoDB';
          $table-&gt;increments('id');
          $table-&gt;integer('partner_id')-&gt;unsigned();
          $table-&gt;string('email', 70)-&gt;unique();
          $table-&gt;string('first_name', 50);
          $table-&gt;string('last_name', 50);
          $table-&gt;string('password', 60);
          $table-&gt;string('image', 200)-&gt;nullable();
          $table-&gt;string('gender', 10)-&gt;nullable();
          $table-&gt;string('phone', 25)-&gt;nullable();
          $table-&gt;string('nationality', 50)-&gt;nullable();
          $table-&gt;string('address', 200)-&gt;nullable();
          $table-&gt;boolean('is_active')-&gt;default(0);
          $table-&gt;string('single_signon', 30)-&gt;nullable();
  
          // Checks if mysql or mariadb supports json data type
          if ((DB::connection()-&gt;getPdo()-&gt;getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') &amp;&amp; version_compare(DB::connection()-&gt;getPdo()-&gt;getAttribute(PDO::ATTR_SERVER_VERSION), '5.7.8', 'ge')) {
              $table-&gt;json('settings')-&gt;nullable();
          } else {
              $table-&gt;text('settings')-&gt;nullable();
          }
  
          $table-&gt;softDeletes();
          $table-&gt;rememberToken();
          $table-&gt;timestamps();
          $table-&gt;foreign('partner_id')-&gt;references('id')-&gt;on('partners')-&gt;onDelete('cascade');
      });
  }
  
  public function down()
  {
      Schema::table('users', function(Blueprint $table) {
          $table-&gt;dropForeign('users_partner_id_foreign');
      });
  
      Schema::drop('users');
  }
  </code></pre>
  
  <p><strong>Last i call the notification migration:</strong></p>
  
  <pre><code>public function up()
      {
          Schema::create('notifications', function (Blueprint $table) {
              $table-&gt;engine = 'InnoDB';
              $table-&gt;increments('id');
              $table-&gt;integer('user_id')-&gt;unsigned();
              $table-&gt;string('notification_type', 10);
  
              // Checks if mysql or mariadb supports json data type
              if ((DB::connection()-&gt;getPdo()-&gt;getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') &amp;&amp; version_compare(DB::connection()-&gt;getPdo()-&gt;getAttribute(PDO::ATTR_SERVER_VERSION), '5.7.8', 'ge')) {
                  $table-&gt;json('notification')-&gt;nullable();
              } else {
                  $table-&gt;text('notification')-&gt;nullable();
              }
              $table-&gt;boolean('seen');
              $table-&gt;timestamps();
              $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users')-&gt;onDelete('cascade');
          });
      }
  public function down()
  {
      Schema::table('notifications', function(Blueprint $table) {
          $table-&gt;dropForeign('notifications_user_id_foreign');
      });
      Schema::drop('notifications');
  }
  </code></pre>
  
  <p>Can anybody figure out whats wrong with this? i am using laravel 5.3 and php7</p>