5

I noticed in the Magento Certified Developer Study Guide, under the Database section one of the items mentioned is "Write downgrade (rollback) scripts".

I've done some searching to see whether downgrade scripts are supported and it seems they are not. I found this thread from earlier this year in which it seems they concluded that downgrade scripts weren't supported at that time.

Also, did some searching on google and found this article discussing what appears to be some initial support for rollback scripts in the core.

I also searched under app/code/core/Mage for "rollback" and "downgrade" and pretty much most of what I found was code related to DB transaction rollbacks.

Why would the study guide be talking about this if it's not supported? I must be missing something.

Community
  • 1
  • 1
kalenjordan
  • 2,446
  • 1
  • 24
  • 38

2 Answers2

5

Current versions of Magento have no implementation for rollback database migration scripts, where rollback means identifying that a module version number has decreased and running an appropriate script.

Remember through, you're looking at a study guide, not a manual.

While there's no support for formal rollbacks in the current version of Magento, as a Magento developer you may need to rollback database changes made in a previous module upgrade. I'd be ready for questions that describe that scenario, with answers that test your knowledge of existing Magento functionality.

Alana Storm
  • 164,128
  • 91
  • 395
  • 599
  • Thanks Alan, sure makes sense. Blasted study guide has me all over the map. It's really written quite well I think from the perspective of giving you enough to sink your teeth into but not giving you everything so literally that you still have to do quite a bit of practicing and digging. Well, my next question is how to hook into the event where Magento detects a version number decrease - outside of just simply overriding that one class - but I'll do some more digging before I post that question. – kalenjordan Dec 27 '11 at 21:44
0

It's here: Mage_Core_Model_Resource_Setup::applyUpdates() Available, at least, from Magento 1.3.

vsushkov
  • 2,445
  • 1
  • 19
  • 28
  • 1
    Hm, but when I trace that down into _modifyResourceDb(), it seems like the TYPE_DB_ROLLBACK $actionType isn't supported? It's just missing from the switch statement. You don't happen to have an example rollback script lying around somewhere? Or does it just programatically reverse the setup steps from the setup script? – kalenjordan Dec 27 '11 at 09:44
  • 1
    Oh, you are right. From `_modifyResourceDb` method if clear that rollback and uninstall does not work :) – vsushkov Dec 27 '11 at 09:50
  • BUT you can write your own setup class which will support rollback and uninstall (see the `Mage_Core_Model_Resource_Setup::applyAllUpdates()`, string `$setupClass = new $className($resName);`) – vsushkov Dec 27 '11 at 09:56