BitBagCommerce / SyliusCmsPlugin

Content management system for eCommerce apps created on Sylius platform. Built with Sylius code quality, flexibility, BDD.
MIT License
234 stars 159 forks source link

FK constraint fails on block and page deletion due to a missing cascade #190

Closed ambroisemaupate closed 5 years ago

ambroisemaupate commented 6 years ago
An exception occurred while executing 'DELETE FROM bitbag_cms_block WHERE id = ?' with params [4]: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`chni_eu`.`bitbag_cms_block_products`, CONSTRAINT `FK_C4B9089FC4663E4` FOREIGN KEY (`page_id`) REFERENCES `bitbag_cms_block` (`id`))

Steps to reproduce:

I suspect this to be due to ORM mapping which misses a onDelete: CASCADE on joinColumn:

https://github.com/BitBagCommerce/SyliusCmsPlugin/blob/master/src/Resources/config/doctrine/Block.orm.yml#L26

You should add onDelete: CASCADE on joinColumn, Doctrine does not add them by default on joinColumn and inverseJoinColumn if you are changing columns configuration. Here, it’s the missing CASCADE on joinColumn which is faulty and prevent me to delete a block or a page since they’re linked to a product.

nicoplh commented 6 years ago

Hi,

Is it possible to merge those changes ? :)

mikemix commented 6 years ago

Same here, cannot delete blocks.

bitbager commented 6 years ago

Can I ask you guys to provide a PR?

Holicz commented 6 years ago

Would it be possible to merge this? :)

aayaresko commented 5 years ago

Can I ask you guys to provide a PR?

hello, here you go: #230

aayaresko commented 5 years ago

new pr - #236, build passed

patrick477 commented 5 years ago

Fixed #232