aydin
1
Hi,
I’m trying to edit a user comment thru PHPMyAdmin but it gives me this error:
UPDATE `product_review` SET `product_id` = 0x61507f15533140d8acf164553d71c5d41, `customer_id` = 0x07dbc372228f42dca7b8bb5615e9bfe31, `sales_channel_id` = 0x9bcd4e53fc294760b5964a5471c2275c1, `language_id` = 0x2fbb5fe2e29a4d70aa5854ce7ce3e20b1, `product_version_id` = 0x0fa91ce3e96a4bc2be4bd9ce752c34251 WHERE `product_review`.`id` = CAST(0xf5589c39c8f74b46a1c5ddf80204eb61 AS BINARY)
#1452 - Cannot add or update a child row: a foreign key constraint fails (
aadb1.
product_review, CONSTRAINT
fk.product_review.product_id FOREIGN KEY (
product_id,
product_version_id) REFERENCES
product (
id,
version_id) ON DELETE CASCADE ON UPD)
Any solution to this?
Thanks in advance.
aydin
2
Hi all
I just dropped the constraint from the table structure, now I can update the user reviews as I wish.
Can I leave like this or should I add the constraints?
ALTER TABLE product_review
ADD CONSTRAINT fk.product_review.customer_id
FOREIGN KEY (customer_id
) REFERENCES customer
(id
) ON DELETE SET NULL ON UPDATE CASCADE,
ADD CONSTRAINT fk.product_review.language_id
FOREIGN KEY (language_id
) REFERENCES language
(id
) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT fk.product_review.product_id
FOREIGN KEY (product_id
,product_version_id
) REFERENCES product
(id
, version_id
) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT fk.product_review.sales_channel_id
FOREIGN KEY (sales_channel_id
) REFERENCES sales_channel
(id
);
COMMIT;