Magento Forum

   
SQL Errors During Upgrade
 
PacificDisc
Jr. Member
 
Total Posts:  17
Joined:  2009-02-25
 

I’m trying to upgrade a client’s site from v1.41 to the latest version of Magento Community.

Every time I try to access the existing database, I get the following error:

“C:\wamp\www\clientsite\app\code\core\Mage\Sales\sql\sales_setup\mysql4-upgrade-1.4.0.20-1.4.0.21.php” - SQLSTATE[HY000]: General error: 1452 Cannot add or update a child row: a foreign key constraint fails (`tenis2/#sql-d2c_324`,
CONSTRAINT `FK_PRODUCT_ORDERED_AGGREGATED_DAILY_STORE_ID` FOREIGN KEY (`store_id`)
REFERENCES `dxov_core_store` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE)

I’m seeing duplicate entries in the database and thought that cleaning the database would resolve this issue. It didn’t!!

Any insight would be greatly appreciated.

Thanks

Sean

 
Magento Community Magento Community
Magento Community
Magento Community
 
greenshopping
Jr. Member
 
Total Posts:  10
Joined:  2010-09-28
 

I’m getting the same error - did you get anywhere with this Sean?

 
Magento Community Magento Community
Magento Community
Magento Community
 
greenshopping
Jr. Member
 
Total Posts:  10
Joined:  2010-09-28
 

For anyone encountering this error, the solution is to find the products listed in the three ‘aggregated bestsellers’ tables that are no longer in your catalog and delete them.

The SQL to do it is:

DELETE FROM `sales_bestsellers_aggregated_yearly`
WHERE `product_idNOT
IN 
(SELECT `entity_id`
FROM `catalog_product_entity`
)

...and then running twice more, replacing ‘yearly’ in the table name with ‘monthly’ and ‘daily’ respectively.

If you want to play it safe, replace the ‘DELETE’ statement with a ‘SELECT’ statement, run in phpMyAdmin, and then check all the records that show up and delete them.

You might lose a bit of bestseller data for your older products, but on the other hand, you should be able to go live on 1.5.0.1!

EDIT: I’ve just noticed my error was slightly different to Sean’s - same .php file; different tables. Still, hope this helps someone.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top