php - sql error when seeding Specified key was too long for email -
hi started new project in laravel it's latest version 5.4, i'm getting error when seeding database single user , i'm getting error
[illuminate\database\queryexception] sqlstate[42000]: syntax error or access violation: 1071 specified key t oo long; max key length 1000 bytes (sql: alter table users
add unique users_email_unique
(email
))
[pdoexception] sqlstate[42000]: syntax error or access violation: 1071 specified key t oo long; max key length 1000 bytes
user::create([ 'name' => 'someone' 'email' => 'someone@outlook.com', 'password' => bcrypt('mypassword'), ]); <?php use illuminate\support\facades\schema; use illuminate\database\schema\blueprint; use illuminate\database\migrations\migration; class createuserstable extends migration { /** * run migrations. * * @return void */ public function up() { schema::create('users', function (blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->remembertoken(); $table->timestamps(); }); } /** * reverse migrations. * * @return void */ public function down() { schema::dropifexists('users'); } }
you should try like:
use illuminate\support\facades\schema; // @ top of file
and add line in boot() method of appserviceprovider :
schema::defaultstringlength(191);
hope work !!!
Comments
Post a Comment