2017-08-18 1 views
0

こんにちは私はlaravelの最新プロジェクトを開始しましたので、最新のバージョン5.4になってしまいました。このエラーシード時にsqlエラーが発生しました指定されたキーが電子メールで長すぎました

[Illuminate \ Database \ QueryException] SQLSTATE [42000]:構文エラーまたはアクセス違反:1071指定されたキーはt でした。最大鍵長は1000バイトである(SQL:テーブルを変更usersユニーク を追加users_email_uniqueemail))

[PDOException] SQLSTATE [42000]:構文エラーまたはアクセス違反:1071指定されたキーは、ロングT OOました。この作品を

Schema::defaultStringLength(191); 

希望:

use Illuminate\Support\Facades\Schema; // At the top of your file 

そしてAppServiceProviderのブート()メソッドに次の行を追加します。最大キー長は、あなたがこのように試してみてください1000バイト

User::create([ 
    'name' => 'someone' 
    'email' => '[email protected]', 
    'password' => bcrypt('mypassword'), 
]); 


<?php 

use Illuminate\Support\Facades\Schema; 
use Illuminate\Database\Schema\Blueprint; 
use Illuminate\Database\Migrations\Migration; 

class CreateUsersTable extends Migration 
{ 
    /** 
    * Run the 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 the migrations. 
    * 
    * @return void 
    */ 
    public function down() 
    { 
     Schema::dropIfExists('users'); 
    } 
} 
+2

[Laravelの移行:固有キーが指定されていても長すぎます](https://stackoverflow.com/questions/23786359/laravel-migration-unique-key-is-too-long-even-if) -specified) –

+0

あなたの質問は、上記のリンクの近くにあるようです。 –

答えて

0

ですあなたのために !!!