-
Notifications
You must be signed in to change notification settings - Fork 93
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
Use on delete cascade on foreign keys #199
base: dev
Are you sure you want to change the base?
Conversation
@@ -37,7 +37,7 @@ class ProductCommentGrade | |||
/** | |||
* @ORM\Id | |||
* @ORM\ManyToOne(targetEntity="ProductComment") | |||
* @ORM\JoinColumn(name="id_product_comment", referencedColumnName="id_product_comment") | |||
* @ORM\JoinColumn(name="id_product_comment", referencedColumnName="id_product_comment", onDelete="CASCADE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of this Doctrine magic, we can remove the manual Grade deletion at https://github.com/PrestaShop/productcomments/blob/dev/src/Repository/ProductCommentRepository.php#L117
and mark the corresponding function as Deprecated too https://github.com/PrestaShop/productcomments/blob/dev/src/Repository/ProductCommentRepository.php#L560
@@ -37,7 +37,7 @@ class ProductCommentReport | |||
/** | |||
* @ORM\Id | |||
* @ORM\ManyToOne(targetEntity="ProductComment") | |||
* @ORM\JoinColumn(name="id_product_comment", referencedColumnName="id_product_comment") | |||
* @ORM\JoinColumn(name="id_product_comment", referencedColumnName="id_product_comment", onDelete="CASCADE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to Grade
@@ -37,7 +37,7 @@ class ProductCommentUsefulness | |||
/** | |||
* @ORM\Id | |||
* @ORM\ManyToOne(targetEntity="ProductComment") | |||
* @ORM\JoinColumn(name="id_product_comment", referencedColumnName="id_product_comment") | |||
* @ORM\JoinColumn(name="id_product_comment", referencedColumnName="id_product_comment", onDelete="CASCADE") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to Grade
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'd better remove Manual delete after Switching to Doctrine cascade delete.
@leemyongpakva What do you mean by A working delete button for product comments is a must! |
@leemyongpakva The option to delete a comment in BO will call this snippet https://github.com/PrestaShop/productcomments/blob/dev/productcomments.php#L210-L218, that in turn call https://github.com/PrestaShop/productcomments/blob/dev/src/Repository/ProductCommentRepository.php#L117-L119 |
@leemyongpakva I see. Are you sure, the FK are present in your DB ? When I create them in my DB, deletion of a comment no longer works in the BO, unless I also add |
@lmeyer1 I have just tried deleting a product comment on a PS 8.1.2 site with ProductComment 6.0.2, and the related grades, reports and usefulness are deleted as well. There is no error at all. |
@leemyongpakva What is the output of |
Sure, there it is
It looks like I haven't got a chance to break my database myself ;) Let's wait other devs checking. |
on delete cascade
in order to allow deletion of a product comment.php bin/console doctrine:schema:update --dump-sql
and compare the output. Apply both versions of the SQL script to the DB and test for each the deletion of a product comment in the BO