Zizaco / entrust

Role-based Permissions for Laravel 5
MIT License
6.05k stars 1.29k forks source link

Migrate error #951

Closed DivingPigy closed 5 years ago

DivingPigy commented 5 years ago

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.

Sir, may I get some help from you?

DivingPigy commented 5 years ago

I find another substitue, sorry for open this issue