我试图为我的用户表创建一个新的迁移,我有以下模式:
Schema::create('users', function($t) {
$t->increments('id');
$t->string('username', 16);
$t->string('password', 64);
$t->integer('role', 64);
$t->timestamps();
});当我尝试从终端运行php迁移时,我会得到以下错误:
异常 SQLSTATE42000:语法错误或访问冲突: 1075个不正确的表定义;只能有一个自动列,它必须定义为一个键(SQL: create
users(idint unsigne d not null auto_increment主键,usernamevarchar(16) null,passwordvarchar(64) not null,roleint null auto_increment主键,created_at时间戳默认值0 null)) (绑定:数组(绑定: ))
该错误与“角色”字段有关,因为当删除该字段时,它似乎运行良好。
提前感谢您的帮助或见解。
发布于 2013-02-18 08:13:11
integer的第二个参数是自动增量标志。
public function integer($column, $autoIncrement = false, $unsigned = false)https://github.com/laravel/framework/blob/5.4/src/Illuminate/Database/Schema/Blueprint.php#L510
发布于 2016-01-22 17:08:23
整数的长度属性不是permitted.Remove,它并没有尝试。
https://stackoverflow.com/questions/14931802
复制相似问题