我正在尝试为我的users表创建一个新的迁移,我有以下架构:
Schema::create('users', function($t) {
$t->increments('id');
$t->string('username', 16);
$t->string('password', 64);
$t->integer('role', 64);
$t->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
当我尝试从终端运行php artisan migrate时,我收到以下错误:
[例外]
SQLSTATE [42000]:语法错误或访问冲突:1075表定义不正确; 只能有一个自动列,必须将其定义为键(SQL:create tableusers(idint unsigne d not null auto_increment primary key,usernamevarchar(16)not null,passwordvarchar(64)no t null,roleint not null auto_increment primary key,created_attimestamp default 0 not null,updated_attimestamp default 0 not null))(Bindings:array(
))
该错误与"角色"字段有关,因为当删除它时,它似乎运行正常.
在此先感谢任何帮助或见解.
Rob*_*bbo 13
第二个参数integer是自动增量标志.
public function integer($column, $autoIncrement = false, $unsigned = false)
Run Code Online (Sandbox Code Playgroud)
https://github.com/laravel/framework/blob/5.4/src/Illuminate/Database/Schema/Blueprint.php#L510
| 归档时间: |
|
| 查看次数: |
6779 次 |
| 最近记录: |