tôi đang cố gắng để tạo ra một sự chuyển đổi mới cho bảng người dùng của tôi, tôi có giản đồ sau:Laravel 4 - Artisan lỗi SQLSTATE [42000]
Schema::create('users', function($t) {
$t->increments('id');
$t->string('username', 16);
$t->string('password', 64);
$t->integer('role', 64);
$t->timestamps();
});
Khi tôi cố gắng chạy php nghệ nhân di chuyển từ nhà ga, Tôi nhận được lỗi sau:
[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 (
))
Lỗi có liên quan đến trường 'vai trò', khi điều này bị xóa, dường như hoạt động tốt.
Cảm ơn trước vì bất kỳ trợ giúp hoặc thông tin chi tiết nào.
Tại sao SQL được tạo đặt 'vai trò' thành' auto_increment khóa chính'? Có gì sai với 'id' là cột' auto_increment primary key' duy nhất? –