Larabel迁移文件发生错误怎么办?

下面由laravel教程栏目带大家介绍关于larabel迁移文件时报sqlstate[42000]错误的解决方法,希望对大家有所帮助!

Larabel迁移文件发生错误怎么办?

                                                                               

Laravel执行php artisan migrate命令时,报如错误的解决方法

IlluminateDatabaseQueryException  :  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long;  max key length is 1000 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))

解决方法

修改 app/Providers/AppServiceProvider.php文件中添加如下内容:

<?php  namespace AppProviders;use IlluminateSupportServiceProvider;use IlluminateSupportFacadesSchema;class AppServiceProvider extends ServiceProvider{     public function register()     {     }      public function boot()     {         Schema::defaultStringLength(191);     }}

修改部分

Schema::defaultStringLength(191);

相关推荐:laravel

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享