0

I'm trying to drop the foreign key to an existing table using migration but it throws an error as "Syntax error or access violation:1091 cant DROP consultant_id :check that column/key exists". Can you please help with it?

2 Answers2

1

First of all, you have to drop Foreign constraint.

public function up() {
       Schema::table('table_name', function (Blueprint $table) {
            $table->dropForeign('table_name_consultant_id_foreign');
            $table->dropColumn('consultant_id');
        });

    }
0

disable foreign key checks before you drop the table then enable them

DB::statement('SET FOREIGN_KEY_CHECKS=0;');
Schema::dropIfExists('your_choice_table');
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
albus_severus
  • 3,626
  • 1
  • 13
  • 25