Hi:
I have done things according to the manual, then run the php artisan migrate
However, error reported in the console:
PDOException::("SQLSTATE[HY000]: General error: 1005 Can't create tabletest.#sql-2854_16(errno: 150 "Foreign key constraint is incorrectly formed")")
If I remove these:
$table->foreign('user_id')->references('id')->on('users') ->onUpdate('cascade')->onDelete('cascade'); $table->foreign('role_id')->references('id')->on('roles') ->onUpdate('cascade')->onDelete('cascade');
the artisan command will migrate success.
I can not get the cause:Foreign key constraint is incorrectly formed. Because the same code show up in the permission_role table, as below:
$table->foreign('user_id')->references('id')->on('users') ->onUpdate('cascade')->onDelete('cascade'); $table->foreign('role_id')->references('id')->on('roles') ->onUpdate('cascade')->onDelete('cascade');
This migrate success and comfused me a lot.
Hi: I have done things according to the manual, then run the
php artisan migrate
However, error reported in the console:PDOException::("SQLSTATE[HY000]: General error: 1005 Can't create table
test.
#sql-2854_16(errno: 150 "Foreign key constraint is incorrectly formed")")
If I remove these:
$table->foreign('user_id')->references('id')->on('users') ->onUpdate('cascade')->onDelete('cascade'); $table->foreign('role_id')->references('id')->on('roles') ->onUpdate('cascade')->onDelete('cascade');
the artisan command will migrate success.I can not get the cause:Foreign key constraint is incorrectly formed. Because the same code show up in the
permission_role
table, as below:$table->foreign('user_id')->references('id')->on('users') ->onUpdate('cascade')->onDelete('cascade'); $table->foreign('role_id')->references('id')->on('roles') ->onUpdate('cascade')->onDelete('cascade');
This migrate success and comfused me a lot.Sir, may I get some help from you?