Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 2 years ago.
0
$table->primary(array('username', 'email'));

Because id is already defined as primary key via bigIncrements. I could be wrong though.

Last updated 2 years ago.
0

mgsmus said: Because id is already defined as primary key via bigIncrements. I could be wrong though.

just so!

fariss, for greater flexibility you could use 'bigInteger' instead of 'bigIncrements' as well

bigInteger($column, $autoIncrement = false, $unsigned = false)

like so

$table->bigInteger('id', true, true);

$table->primary(array('id', 'username', 'email'));

result should be the same

Last updated 2 years ago.
0

Though this is bug from Laravel, as we should drop all primary key(s) which is exists before add new one using alter method. Afaik autoincrement column must be set to be primary key and it done automatically in laravel (CMIW). For me, username and email better serve as unique_id rather than primary :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

fariss fariss Joined 21 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.