Delete foreign key with migrate reset?

Published 4 months ago by mediax

When I try to run php artisan migrate reset I get following errors:

SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or update a parent row: a foreign key constraint fails (SQL: drop table `blog_groups`) 

SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or update a parent row: a foreign key constraint fails  

In the function down() I tried to add:

Schema::table('blog_groups', function($table) { $table->dropForeign('blog_groups_item_id_foreign');
});

But this don't works I get the same error. What I'm doing wrong here?

If I use Schema::enableForeignKeyConstraints(); and Schema::disableForeignKeyConstraints(); is this dangerous for production system after deployment?

jimmy0699

have you try? :

Schema::table('blog_groups', function(Blueprint $table) { $table->dropForeign(['item_id']);
});
mediax

@jimmy0699 I get the same error, I tried also to do in both migrations...

Sign In or create a forum account to participate in this discussion.