Magento 1.6 Upgrade

Posted by Jamie Neil on 15 September 2011

There's nothing quite like a major Magento upgrade to help you lose the best part of a day. We've been holding a number of sites at 1.4 for a while now due to compatibility problems with Magento 1.5, but with the release of 1.6.0 I thought it best to at least see how painful it was going to be.

The upgrade itself went pretty smoothly, and, after trying to access the upgraded site for the first time, the database changes were kicked off. The site I was running the test on was fairly large (4000+ skus and lots of sales history), but after 15 mins of watching the hourglass I suspected something was up. Monitoring the queries being run everything looked fine though, and I actually starting thinking it might be a trouble free upgrade. Right on cue the error message appeared, and looking at the error report I saw the usual cryptic SQL error:

a:4:{i:0;s:260:"Error in file: "/xxx/public_html/shop/app/code/core/Mage/

Sales/sql/sales_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php"

- SQLSTATE[HY000]: General error: 1025 Error on rename of

'./xxx/#sql-25de_742' to './xxx/sales_flat_order_item' (errno: 150)

";i:1;s:1076:"#0 /xxx/public_html/shop/app/code/core/Mage/Core/Model/

Resource/Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...')

 

Oh Joy.

After a bit of googling, it appears that I am not alone. One of the more common pieces of advice with these kind of errors is to disable sql key constraints. I'm not keen on doing this, because I'm concerned that other problems might pop up later on once it's all live. So I started my usual dig through the upgrade file to see if I could identify the culprit, and for once it was actually pretty simple. Once I had commented out the rogue command, the upgrade continued without further problems and the site loaded fine. I didn't even have to reimport the old database and start again.

So here's my step by step guide to upgrade from Magento 1.4.2 to 1.6.0:

  • Ideally do the upgrade on a separate developement server before you update your live site. We use subversion to push the updated site up to the live server and then let it do the database upgrade, but at the very least, backup your site and database so you can roll back.
  • Turn off web access to your site and disable any cron jobs that might run during the upgrade. You don't want the sql update scripts running at the wrong time.
  • Use ./pear to upgrade Mage_All_Latest. This thread goes through some of the different options.
  • Once the code is updated, don't try to access the site yet. First of all clear out the cache and session store by deleting var/cache and var/session.
  • In order to get the upgrade to complete, I needed to edit "app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php" and comment out the command starting on line 753.
  • Run the upgrade from the command line: nohup php index.php > 1.6-upgrade.log &
    and wait.... (it may take some time)
  • Assuming everything finishes ok (and it did for me once I'd patched the update file), you can now reindex: php shell/indexer.php reindexall
  • Finally re-enable access to the site and you should be done (apart from trying to spot which of the latest round of API changes has screwed up your custom theme).
Hope that's of some help to someone. Can't wait for the 2.0 upgrade...

Comments (9)

  • Rich Rich on September 16th, 2011

    You love a bit of Magento pain!

  • Justin Snyder Justin Snyder on September 20th, 2011

    Thanks for the post! It allowed me to upgrade but I'm concerned it caused other issues.. now when i try to update existing categories i get the error message: "XML data is invalid"

    Any ideas?

  • Jamie Neil Jamie Neil on September 20th, 2011

    Don't seem to be getting that problem on the site I'm working on at the moment. Are you sure it's related?

    I do seem to remember a similar problem with categories in the past that was caused by the parent category not being set up properly. Check to see if the save problem affects all categories or just certain child ones.

  • Magento Upgrade Magento Upgrade on October 15th, 2011

    This is a great tutorial to help update your magento version. It is so annoying when you get stuck trying to do the update all your self. Things like this really do help.

  • Alexander Alexander on November 1st, 2011

    Super Guide. Thank you it helped me a lot!

  • Jelle Jelle on February 3rd, 2012

    Thanks man, this really saved me a ton of time! Keep up the good work!

  • David David on February 29th, 2012

    Thanks for this info. Can you clarify how you identified which line in the sql upgrade script was causing the issue?

  • lxwebsolutions lxwebsolutions on March 29th, 2012

    nice share and i have the same query as David please answer it

  • Callum Callum on June 21st, 2012

    OMG. I worship you. I put my head on the ground and kiss your feet!

Post your comment