laravel migration add unique column
Schema::table('tableName', function($table)
{
$table->string('column-name')->unique(); //notice the parenthesis I added
});
laravel migration add unique column
Schema::table('tableName', function($table)
{
$table->string('column-name')->unique(); //notice the parenthesis I added
});
laravel migration remove unique
//The UNique need be a constraint name
// This name has this format:
// [TABLE_NAME]_[COLUMN_NAME]_unique
// For 'users' table and 'user_code' column, whe get the name:
// users_user_code_unique
$table->dropUnique('users_user_code_unique');
//The inverst is
$table->unique('user_code');
unique laravel migration
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
Schema::table('users', function (Blueprint $table) {
$table->string('email')->unique();
});
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us