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

fix: delete child collection item #1979

Closed

Conversation

ferdiunal
Copy link
Contributor

It gives an error because the collection to be deleted is linked to the ‘Customer Group’ table and the foreign key index.

image

It gives an error because the collection to be deleted is linked to the ‘Customer Group’ table and the foreign key index.
Copy link

vercel bot commented Oct 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 14, 2025 5:30pm

@ferdiunal ferdiunal changed the title Delete Child Collection Item fix: delete child collection item Oct 5, 2024
@alecritson
Copy link
Collaborator

Thanks @ferdiunal Can you provide some steps on how to reproduce as I currently can't seem to :)

@rjvandoesburg
Copy link
Contributor

I can reproduce the issue simply by creating a new root collection and then adding a single collection to that root.
When i try to delete the collection (not the root) I get the same error.

I have to manually delete the record from lunar_collection_customer_group before i can delete the collection via the admin.

This should be solvable by adding cascadeOnDelete() on the constraints, this also allows developers to delete records outside of Lunar.

@glennjacobs
Copy link
Contributor

An issue still resides if you try to delete a parent collection, as it won't remove the customer group relations for the child collections.

I'm not too sure why this is still an issue, as we have the detach in the observer, see here
https://github.com/lunarphp/lunar/blob/1.x/packages/core/src/Observers/CollectionObserver.php

@glennjacobs
Copy link
Contributor

Thanks for the submission, but I think this is the wrong approach. I will open a separate PR to resolve this, after I've consulted @alecritson

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

4 participants