jcadima
8/12/2017 - 7:36 PM

Laravel [Illuminate\Database\QueryException]

Laravel [Illuminate\Database\QueryException]

https://laravel-news.com/laravel-5-4-key-too-long-error

this will fix this bullshit 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 uni
  que `users_email_unique`(`email`))
  



************ /app/Providers/AppServiceProvider.php  ***************

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

// Include this bullshit
use Illuminate\Support\Facades\Schema;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // https://laravel-news.com/laravel-5-4-key-too-long-error
        // Fix Laravel 5.4 bullshit change to utf8mb4:
        Schema::defaultStringLength(191) ;
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}