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

Cascade DELETEs in the database #363

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft

Conversation

gtfierro
Copy link
Collaborator

@gtfierro gtfierro commented Jan 15, 2025

I'm pretty sure the issue is that if I create library A with templates, and then I create library B which depends on A through B's templates, and the nI delete library A, I need to decide what happens to A's templates and B's templates' dependencies on A's templates. Right now (outside of this PR) I think we leave dangling references, which causes exceptions in SQLalchemy when you interact with that table after messing with the dependency structure.

@TShapinsky TShapinsky self-assigned this Feb 17, 2025
@TShapinsky
Copy link
Member

@gtfierro I just rebased which mostly required changes around of exceptions, cause your adding exceptions PR went through to develop. Let me know if anything looks messed up.

@TShapinsky
Copy link
Member

Documenting what appears to be the desired functionality so that it can be tested.

On Model Delete

  • Delete associated shape collection

On Library Delete

  • Delete shape collection
  • Delete all templates owned by library
  • Delete all dependency relationships associated with deleted templates.

Standing issues:

  • What happens when you delete a library which has templates depended on by another libraries templates.

@gtfierro
Copy link
Collaborator Author

This looks great, @TShapinsky ! Thanks for doing the merge. I just wrote a couple unit tests to verify the behavior under different conditions.

I decided to see what would happen if we had a default CASCADE between dependencies.
Currently, the test_cascade_delete_dependency_multi_library test fails because it specifies that if I delete the library my template is dependent on, then that should also delete the whole library (this is the behavior I am proposing). What do you think of this behavior?

@TShapinsky
Copy link
Member

This looks great, @TShapinsky ! Thanks for doing the merge. I just wrote a couple unit tests to verify the behavior under different conditions.

I decided to see what would happen if we had a default CASCADE between dependencies. Currently, the test_cascade_delete_dependency_multi_library test fails because it specifies that if I delete the library my template is dependent on, then that should also delete the whole library (this is the behavior I am proposing). What do you think of this behavior?

So if a library is deleted it should cascade delete all libraries which have dependent links to that library.

I think that makes sense. We should make sure that the deletes don't accidentally cascade the other direction. I haven't looked at your new tests yet so you may have already addressed that. Unless we want to go through the process of rebuilding dependencies for all libraries anytime one is imported I think this is the right call.

One other thought. If this isn't already the case, we should make sure that you can hotswap a library without destroying the entire dependency tree. For Example: if you overwrite a library it should rebuild the dependencies but not cascade delete everything. This could probably be a different issue.

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.

2 participants