我试图运行php artisan migrate命令,但我得到像唯一,索引等每个约束的语法错误发布错误是从默认不变的create_users_table迁移,因为它是第一次迁移到处理。当我从邮件列中删除这个唯一约束时,在下一次迁移中,我得到了另一个约束的相同错误。我认为错误信息中显示的'设备唯一'可能存在错误。它应该是“添加独特”。Laravel迁移约束语法错误
错误
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server version for
the right syntax to use near 'devices unique `users_email_unique`(`email`)'
at line 1 (SQL: alter table `users` devices unique `users_email_unique`(`email`))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'devices unique
`users_email_unique`(`email`)' at line 1
迁移
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
.ENV
APP_NAME=Project
APP_ENV=local
APP_KEY=base64:jRIQ9RxhMYRK9UJXgme1KlA6bd1rA0OGyK96SdBP1nI=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://project.dev
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=project
DB_USERNAME=homestead
DB_PASSWORD=secret
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
感谢您的帮助。
请勿发布错误消息的图像。作为文本完整发布错误消息。另外,显示你的代码。 – klutt
好的,对不起,我正确地编辑了我的帖子。 –