I'm trying for migrate a laravel migration but i had an error :
Migrating: 2014_10_12_100000_create_password_resets_table
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 `password_
resets` add index `password_resets_email_index`(`email`))
my code is :
if (!Schema::hasTable('password_resets')) {
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
You can set String Length manually by putting this
$table->string('name', 191); // You can put any number in exchange of 191
else
Put This in APP -> Providers -> AppServiceProvider
use Illuminate\Support\Facades\Schema;
public function boot()
{
Schema::defaultStringLength(191);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With