Posted in

Problema migration en Laravel 5.7

Si al realizar un migration nos aparece el siguiente error:

Illuminate\Database\QueryException  : SQLSTATE[42000]: Syntax error or access
 violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL:
alter table `users` add unique `users_email_unique`(`email`))

Deberemos hacer lo siguiente, abrir el AppServiceProvider.php y añadir en el boot() la longitud por defecto del campo string de la siguiente forma:

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

Deixa un comentari

L'adreça electrònica no es publicarà. Els camps necessaris estan marcats amb *


The reCAPTCHA verification period has expired. Please reload the page.