Specified key was too long error in Laravel 5.4
From version 5.4 Laravel used for a default database character – utf8mb4. This charset includes support for storing emojis.
If you are running MySQL v5.7.7 or greater you don`t have his problem, but if you used MariaDB before version 10.2.3 or older versions of MySQL you may hit this error when trying to run migrations:
[Illuminate\Database\QueryException] SQLSTATE: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
How to fix this?
All you have to do is edit your AppServiceProvider.php file and, inside the boot method set a default string length:
public function boot()