Dropping foreign keys in Laravel migration

后端 未结 3 2477
花落未央
花落未央 2021-02-20 14:58

I have a problem with dropping some foreign keys from my Laravel application. The problem is when I am trying to rollback the migration:

php artisan migrate:roll         


        
3条回答
  •  猫巷女王i
    2021-02-20 15:43

    In all of the >4.0 versions of Laravel, it allows placing column names into an array, which it will then resolve on its own. I tried to find accompanying docs, but they seem to have left it out.

    In your update migration, try this:

    Schema::table('role_user', function (Blueprint $table) {
      $table->dropForeign(['user_id']);
      $table->dropForeign(['role_id']);
    });
    

提交回复
热议问题