23

I'm upgrading a module to version lets say 0.1.3. Say I have these files:

data/mymodule_setup/data-upgrade-0.1.2-0.1.3.php
sql/mymodule_setup/upgrade-0.1.2-0.1.3.php

Will the sql upgrade script run first? The data upgrade script requires a column that will be added in the other script, so if it's not there yet it will fail.

21

The order is

  1. install
  2. install upgrade script
  3. data script
  4. data upgrade script

More info can be found here: http://inchoo.net/magento/magento-install-install-upgrade-data-and-data-upgrade-scripts/

or http://www.sitepoint.com/magento-install-upgrade-data-scripts-explained/

Or thanks to @RickBuczynski the following link: http://vinaikopp.com/2014/11/03/magento-setup-scripts/

Addition: If you have modules that depend on each other, you should know that when several modules are installed/updated at once, first all normal upgrade scripts run, then all data upgrade scripts. Each in the order how the module are loaded, i.e. with regards to dependencies.

  • I have already read both those articles, but there isn't anything in them about the order of execution. Your answer makes sense, but can you confirm with evidence that this is the real order? – Vic Feb 17 '15 at 18:14
  • 2
    I'd also add this URL for reference: vinaikopp.com/2014/11/03/magento-setup-scripts Seems to be the best in-depth info I've ever read on the subject. – Rick Buczynski Feb 17 '15 at 18:14
  • @Vic see the link from Rick. – JELLEJ Feb 17 '15 at 18:15
  • @RickBuczynski wow, amazing article! – JELLEJ Feb 17 '15 at 18:16
  • 2
    Nah, it's all good. All 3 resources are useful, depending on your level of experience with this area. I'll get my points some other time :-p – Rick Buczynski Feb 17 '15 at 18:51
2

the magento follow this order

  1. install
  2. install upgrade script
  3. data script
  4. data upgrade script

the interesting starts if

in 1st script you insert data (create website)

and in 2nd script you read that data (category finds website)

  1. magento install scripts are run within one transaction
  2. magento upgrade scripts are run in other transaction
  3. the default mysql transaction isolation level REPEATABLE READ

have fun

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.