我正在尝试为我的用户表创建一个新的迁移,我有以下架构:
Schema::create('users', function($t) {
$t->increments('id');
$t->string('username', 16);
$t->string('password', 64);
$t->integer('role', 64);
$t->timestamps();
});
当我尝试从终端运行 php artisan migrate 时,出现以下错误:
[例外]
SQLSTATE[42000]:语法错误或访问冲突:1075 不正确
表定义;只能有一个自动列,并且必须
被定义为一个键(SQL:create tableusers
(id
int unsigned not null auto_increment 主键,username
varchar(16) 不为空,password
varchar(64) 不为空,role
int 不为空
自动递增主键,created_at
时间戳默认 0 不为空
,updated_at
时间戳默认 0 不为空))(绑定:数组(
))
该错误与“角色”字段有关,因为当删除该字段时,它似乎运行良好。
预先感谢您的任何帮助或见解。
第二个参数为integer
是一个自动递增标志。
public function integer($column, $autoIncrement = false, $unsigned = false)
https://github.com/laravel/framework/blob/5.4/src/Illuminate/Database/Schema/Blueprint.php#L510 https://github.com/laravel/framework/blob/5.4/src/Illuminate/Database/Schema/Blueprint.php#L510
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)