-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
fix: Add Cascade Delete Function for Transactions and Builds Associated with Flows #3848
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit adds a new function `cascade_delete_flow` to the `utils.py` file in the `langflow.api` module. This function is responsible for deleting related records when a flow is deleted. It uses the `delete` method from SQLAlchemy to delete records from the `TransactionTable` and `VertexBuildTable` tables based on the flow ID. Finally, it deletes the flow record itself from the `Flow` table. The function is wrapped in a try-except block to handle any exceptions that may occur during the deletion process. If an exception is raised, a `RuntimeError` is raised with an appropriate error message. This refactor improves the code by encapsulating the cascade delete logic in a separate function, making it more modular and easier to maintain.
dosubot
bot
added
size:L
This PR changes 100-499 lines, ignoring generated files.
enhancement
New feature or request
labels
Sep 18, 2024
github-actions
bot
added
bug
Something isn't working
and removed
enhancement
New feature or request
labels
Sep 18, 2024
This pull request is automatically being deployed by Amplify Hosting (learn more). |
italojohnny
approved these changes
Sep 18, 2024
diogocabral
pushed a commit
to headlinevc/langflow
that referenced
this pull request
Nov 26, 2024
…ed with Flows (langflow-ai#3848) * refactor: Add cascade delete functionality for flows This commit adds a new function `cascade_delete_flow` to the `utils.py` file in the `langflow.api` module. This function is responsible for deleting related records when a flow is deleted. It uses the `delete` method from SQLAlchemy to delete records from the `TransactionTable` and `VertexBuildTable` tables based on the flow ID. Finally, it deletes the flow record itself from the `Flow` table. The function is wrapped in a try-except block to handle any exceptions that may occur during the deletion process. If an exception is raised, a `RuntimeError` is raised with an appropriate error message. This refactor improves the code by encapsulating the cascade delete logic in a separate function, making it more modular and easier to maintain. * refactor: Add cascade delete functionality for flows * refactor: Add cascade delete functionality for flows and folders * refactor: Remove unused delete_flow_by_id function * refactor: Add cascade delete functionality for flows and folders * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a cascade delete function to address an issue where deleting a flow would sometimes fail due to related transactions and builds not being properly removed. The new function ensures that all associated transactions and builds of a flow are deleted before the flow itself is removed. This resolves errors that occurred when attempting to delete folders containing flows.