If you encounter this error when migrating database in your Laravel project, “Specified key was too long” then you might be using an older version of MySQL or MariaDB.
To fix it. Go to your App directory then Providers and open AppServiceProvider.php
Add the Schema Facad at the top “use Illuminate\Support\Facades\Schema;”
Then paste this inside Boot function “Schema::defaultStringLength(191);”
That’s it! Run your migration again.