How to truncate a table within the execution of an action? #6267
Unanswered
michaelklopf
asked this question in
Q&A
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an import action that truncates a table and fills in all the data from an Excel file.
The action looks like this:
The truncate is a DB transaction that is immediately executed. The handle method is wrapped by the framework in a
DB::transaction
statement (at least that's the impression I got when going through the framework code). This will result in the 500 errorThere is no active transaction
. I have found the reason why that is in this issue laravel/framework#38260Despite this, the items are all imported, but I see the error message in Nova and need to refresh the page to see the changes.
I know I can only delete items in the table, but I want the auto increment to be set back. This feels cleaner and more appropriate for the task that is done.
Is it possible to truncate the table outside of the
DB::transaction
context of the action? Something like a beforeActionIsExecuted?Beta Was this translation helpful? Give feedback.
All reactions