Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Add error handling and ensure re-enabling of foreign key constraints #47182

Merged
merged 2 commits into from May 23, 2023
Merged

[10.x] Add error handling and ensure re-enabling of foreign key constraints #47182

merged 2 commits into from May 23, 2023

Conversation

xurshudyan
Copy link
Contributor

This pull request enhances the withoutForeignKeyConstraints method to handle exceptions and ensure proper re-enabling of foreign key constraints. Previously, if an exception occurred within the callback function, the foreign key constraints would not be re-enabled, leading to potential issues.

The changes introduced a try-finally block, allowing for proper error handling. The foreign key constraints are disabled before executing the callback, and regardless of whether an exception is thrown or not, they are always re-enabled using the enableForeignKeyConstraints method.

@taylorotwell taylorotwell merged commit 63ce1c0 into laravel:10.x May 23, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants