Laravel 4 Migration error - creates two auto_increment primary keys fields

蹲街弑〆低调 提交于 2019-12-05 01:04:46

@crynobone: Second parameter are for boolean use to determine primary key, there no length option for integer.

Refer here: https://github.com/laravel/laravel/issues/2212#issuecomment-21608193

In Laravel 4 , second parameter in integer function is for indicating the integer column to be auto incremented or not ( and therefore primary key or not ) In my case , to add an auto incremented id in a table I write it like that

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

It creates an integer column with 11 digits .

Why not specify user_id as primary key with autoincrement?

$table->increments('user_id');
// other columns
...

Schema builder create user_id, which is 10 digits long, unsigned & primary key.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!