私はlaravelのためにマイグレーションファイルに外部キーを設定しようとしているので、userテーブルは単純ですが、スタンドインクリメントの代わりにbigIncrementsを使用しようとしています。外部キーbigIntegerをLaravelのbigIncrementsに設定する5.4
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->string('user_id')->unique();
$table->string('avatar');
$table->string('name');
$table->string('email')->unique();
$table->string('password')->nullable();
$table->rememberToken();
$table->timestampsTz();
});
}
そして私は、私はそれに外部キーを追加しようとする他のテーブルを行うとき、私は、外部キーが誤って形成されているというエラーを取得します。私はどのように私は列の種類に一致するので混乱しています。ここに別の表があります。
public function up()
{
Schema::create('social_logins', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id');
$table->bigInteger('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->unsigned()->index();
$table->string('provider', 32);
$table->string('provider_id');
$table->string('token')->nullable();
$table->string('avatar')->nullable();
$table->timestamps();
});
}
は 'を退治してみてください - 最後に'>インデックス() - >()符号なし外部キーステートメントの – ntzm