Preface
This article mainly introduces the relevant content about migration errors caused by Laravel 5.4 due to too long special fields. It is shared for everyone’s reference and study. I won’t say much below. Let’s take a look at the detailed introduction:
laravel 5.4 changed the default database character set, and now utf8mb4 includes support for storing emojis. MySQL requires v5.7.7 or higher. When you try to run the migrations command on some MariaDB or some older versions of MySQL, you will encounter the following error:
[Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `use rs_email_unique`(`email`)) [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
Solution
After query, we can set a default value in the boot method in the AppServiceProvider.php file:
Copy after login
The above is the detailed content of How to solve the problem of migration error caused by special fields being too long in Laravel5.4 framework. For more information, please follow other related articles on the PHP Chinese website!