我总是在迁移时遇到错误,我能为这种错误做些什么

时间:2017-05-14 09:36:34

标签: php database laravel-5 migration

 [Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table def
inition; there can be only one auto column and it must be defined as a key
(SQL: create table `students` (`id` int unsigned not null auto_increment pr
imary key, `student_id` int unsigned not null auto_increment primary key, `
stuent_name` varchar(50) not null, `student_email` varchar(50) not null, `s
tudent_username` varchar(50) not null, `student_phone` varchar(50) not null
, `student_photo` text not null, `student_sex` varchar(191) not null, `stud
ent_status` varchar(191) not null, `created_at` timestamp null, `updated_at
` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)

我不知道发生了什么,当我尝试迁移时会出现此问题

1 个答案:

答案 0 :(得分:0)

您有两个auto_increment键idstuduent_id。您只能将一个设置为自动增量键。