In this tutorial, we will see how to remove unique constraint from a column using laravel migrations. You can easily remove unique constraint from a column using laravel migrations.

Given below are 2 examples showing how to remove unique constraint from a column using laravel migrations.



Example-1:

class AlterEmailToUsers extends Migration
{
/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::table('users', function (Blueprint $table) {
        $table->string('email')->unique(false)->nullable()->change();
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::table('users', function (Blueprint $table) {
       $table->string('email')->nullable(false)->unique()->change();
    });
}




Example-2:

$table->dropUnique('tableName_columnName_unique');

class AlterEmailToUsers extends Migration
{
/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::table('users', function (Blueprint $table) {
        $table->dropUnique('users_email_unique');
    });
}



I hope this example helps you.