Around CE 1.4, Magento extended their Setup Resource Migration system with the ability to have data updates as well as structure updates. That is, a setup resource upgrade/install script named like this
should contain structural changes to Magento’s database tables, whereas updates named like this (with
data in the name)
should contain changes to a table’s data rows. Modern versions of Magento require data updates to be named without the
mysql4 resource type.
The concept, however, is the same.
What many developers don’t realize is this is more than just an organizational “nice to have”. Structure changes and data changes are applied at different points in the Magento bootstrap process, and this has implications on how they run.
Specifically, Magento applies structure changes with a call to
During normal system operations, this call happens before any event area has been loaded in Magento. This means if a setup resource script dispatches an event (either directly, or by doing something like calling
load on a model), Magento will not call any configured observers.
Magento applies data changes with a call to
Before Magento calls
global event area is loaded. This means during data upgrades Magento will call any observers configured under the
global node, not not call any observers configured under the
adminhtml nodes. This means you can, in theory, use Magento models in your data upgrade scripts with the assurance that important pre/post/load/save observers will be called.
It’s also worth pointing out the above is what I’ve observed in more modern versions of Magento (1.7, 1.8). Changes and bug fixes to the event and setup resource systems, as well as the general non-obviousness of these lower level systems, means the behavior may be different in older versions of Magento