Ad

Laravel: How To Rollback Column Unique

- 1 answer

My table name is customers column is mail I tried with syntax

 public function down()
{
    Schema::table('customers', function (Blueprint $table) {
        $table->dropUnique('mail');
        $table->string('mail',255)->change();
        $table->string('first_name',255)->change();
        $table->string('first_name_reading',255)->change();
        $table->string('last_name',255)->change();
        $table->string('platform',255)->change();
    });
}

But it not work.

   [Illuminate\Database\QueryException]
  SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'mail'; check that column/key exists (SQL: alter
   table `customers` drop index `mail`)

Can you give me your help! Please,

Ad

Answer

Open mysql console and get correct index key name for customers table and use that with your code $table->dropUnique('correct_name');

SHOW INDEX FROM customers;
Ad
source: stackoverflow.com
Ad