Laravel: fix Specified key was too long error
I just started new Laravel app and had an error "Specified key was too long error" during first migration. Reason is simple and described on official Laravel blog - they changed default encondig and it isn't working on MariaDB or MySQL lower than 5.7.7 versions. Fortunately solution is very simple, we must only add two line to file AppServiceProvider.php. First, use Schema facade:
use Illuminate\Support\Facades\Schema;
And second, change boot method to:
public function boot() { Schema::defaultStringLength(191); }
Now it works perfectly. And we also know, when can we change default string lenght for other specific situations :)