【发布时间】:2019-03-08 11:55:30
【问题描述】:
我正在使用 Laravel,当我尝试运行 php artisan make:migrate 时,它显示此错误:
Illuminate\Database\QueryException : SQLSTATE[42000]: 语法错误或访问冲突:1071 指定的键太长;最大密钥长度为 767 字节(SQL:alter table
usersadd uniqueusers_email_unique(在 /Users/soksan/Desktop/TestLaravel/multiUsers/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
异常跟踪:
1
PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes")
/Users/soksan/Desktop/TestLaravel/multiUsers/vendor/laravel/framework/src/Illuminate/Database/Connection.php:4582
PDOStatement::execute()
/Users/soksan/Desktop/TestLaravel/multiUsers/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
请使用参数-v 查看更多详情。
【问题讨论】:
-
你能告诉我们你的迁移代码吗?
-
请添加用户迁移代码