I would like to alter
my one of my column
on my table - and make them a unique index
.
I tried :
public function up()
{
Schema::table('inventories', function($table)
{
$table->string('sku',255)->unique();
});
}
I get :
What is the most efficient way to do that ?
You can add indexes separately from their definition. As documented here
Schema::table('inventories', function($table)
{
$table->unique('sku');
});
I got it.
I did this :
public function up()
{
DB::update('alter table `inventories` modify `sku` VARCHAR(200) UNIQUE NOT NULL');
}
and now It works :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With