Home » Magento7 December 2009

Magento: Upgrading mysql setup of a module

Suppose, you have a module called MyModule. Its version is 0.1.0. Now, you want to do some database changes for the module. You have the mysql setup file (mysql install file) mysql4-install-0.1.0.php in MyModule/sql/mymodule_setup folder of your module.

You don’t need to make direct changes to database. You can upgrade your module to make your necessary database changes. To do so,

1) You need to create a new mysql upgrade file inside MyModule/sql/mymodule_setup folder.

Let us suppose that you are going to change the version of your module from 0.1.0 to 0.1.1.

The mysql upgrade file name should be mysql4-upgrade-0.1.0-0.1.1.php

The upgrade format is like mysql4-upgrade-CURRENT_VERSION-UPGRADED_VERSION.php

2) Write necessary sql statements in the newly added mysql upgrade file.

3) You have to change the version in MyModule/etc/config.xml as well.

Change the version like 0.1.1. 0.1.1 is the new version for our module.

4) Reload your site. And you are done!

Magento

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Abc

    nice, but not working for me

  • Ja

    maybe the format should be mysql4-upgrade-CURRENT_VERSION-UPGRADED_VERSION.php and NOT mysql-upgrade-CURRENT_VERSION-UPGRADED_VERSION.php

  • Genevieve

    If you want to rerun the install script you’ll need to delete the row from core_resource for your extension

  • Where in the database can you see what version is it up to?

  • Yes, you are right. The article is updated. Thanks.

  • “core_resource” table