我想创建为我的用户表的新移民,我有以下模式:Laravel 4 - 工匠错误SQLSTATE [42000]
Schema::create('users', function($t) {
$t->increments('id');
$t->string('username', 16);
$t->string('password', 64);
$t->integer('role', 64);
$t->timestamps();
});
当我尝试运行PHP的工匠从终端迁移,我得到以下错误:
[Exception]
SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create tableusers
(id
int unsigne d not null auto_increment primary key,username
varchar(16) not null,password
varchar(64) no t null,role
int not null auto_increment primary key,created_at
timestamp default 0 not null ,updated_at
timestamp default 0 not null)) (Bindings: array (
))
错误有事情做与“角色”字段,因为当这是删除它看上去一切正常。
在此先感谢您的帮助或见解。
为什么生成的SQL将'role'设置为'auto_increment primary key'? 'id'是唯一的'auto_increment主键'列有什么问题? – 2013-02-18 08:07:36