Specified key was too long; max key length is 767 bytes LARAVEL 5.5

Que tal... nota rápida sobre este error que suele pasarme cada que inicio un proyecto en Laravel 5.5 

Al momento de ejecutar el comando

            php artisan migrate:fresh 

ocurre un error parecido al siguiente

            [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 unique            users_email_unique(email))[PDOException]
            SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long;             max key length is 767 bytes

Dos soluciones:

Modificar config/database.php y modificar las siguientes lineas.

            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci'


Modicar las migraciones CreateUsersTable y CreatePasswordResetsTable, espeficicando un tamaño de String más pequeño
            $table->string('email', 250)->index();

            $table->string('email',250)->unique();
            $table->string('password',250);




Saludos!



UPDATE:
Hoy tuve el mismo error que no fue solucionado con lo anterior, alternativa podría ser lo siguiente:

Migration de password_resets


Schema::create('password_resets', function (Blueprint $table) {
    $table->string('email');
    $table->string('token');
    $table->timestamp('created_at')->nullable();

    $table->unique([DB::raw('email(191)')]);
});


Migration de users

Schema::create('users', function (Blueprint $table) {
    $table->increments('id');
    $table->string('name');
    $table->string('email');
    $table->string('password');
    $table->rememberToken();
    $table->timestamps();

    $table->index([DB::raw('email(191)')]);
});






Entradas populares de este blog

"php" no se reconoce como un comando interno o externo, programa o archivo por lotes ejecutable.

Laravel y MercadoPago SDK

Dompdf image not found or type unknown