Put a size in the field $table->string('email
that will solve the problem, he complains that the size of the field is very large in the creation of the Indice, example of correction that in my understanding the email field does not need to be too large with 100 I believe to be a natural size:
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email', 100)->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Observing: if there are more fields with the type string
and obliged to have a índice
take preventive measures by passing the size.
I also noticed that there are many fields with maximum size, this is not good, need to have a study of their tables, fields and keys, because I prefer to have control of the situation than let the framework make all the decisions.
In addition to this, which in my experience is the best solution, that is, to adjust the sizes of the fields, with previous studies, if using the Laravel 5.4
change two keys in the file config/database.php
:
of:
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
for:
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
Another option, but, that may not be very good because some hosting do not let change the settings of their services is to enable the option innodb_large_prefix
to your database, checking this option in the database MySQL
or MariaDB
.
Finally if you want to put in your migrations
a standard size for string
, open the file app\Providers\AppServiceProvider.php
and put the command Schema::defaultStringLength(191);
with the size 191
, example:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
Schema::defaultStringLength(191);
}
public function register()
{
}
}
These are 4 ways to solve your problem, but I prefer the first, because it gives me and ensures reliability in what I’m planning for my information repository.
References:
The problem was right there, I made the change and it worked, thank you very much
– Thaynan Breno