0

In my users table, I have this column:

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

However, I am getting this 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`))

As per this article, I wrote the following code in AppServiceProvider.php:

use Illuminate\Support\Facades\Schema;

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

However, the issue remains unsolved. Please help!

P.S. I am using Laravel 5.6.*

Axel
  • 4,365
  • 11
  • 63
  • 122

0 Answers0