I kept getting this while run php artisan migrate
SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'email'; check that column/key exists
While I see that email is exist on my database.
My migration script. I was trying to drop the unique constraint.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AlterGuestsTable3 extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('guests', function(Blueprint $table)
{
$table->dropUnique('email');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('guests', function(Blueprint $table)
{
$table->dropUnique('email');
});
}
}
Did I forget to clear any caches ?
Any hints for me ?
By official documentation You can see following:
If you pass an array of columns into a method that drops indexes, the conventional index name will be generated based on the table name, columns and key type:
Schema::table('geo', function ($table) { $table->dropIndex(['state']); // Drops index 'geo_state_index' });
You can drop it just simply using []
around field name:
Schema::table('guests', function(Blueprint $table)
{
$table->dropUnique(['email']);
});
UPD: By the latest docs for 7.x it's still relevant.