Home » Magento

Magento: Upgrading mysql setup of a module

7 December 2009 1,894 views Popularity: 4% Share/Bookmark

email

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!

Related posts:

  1. Magento: Adding attribute from MySql setup file
  2. Magento: Set title, keywords and description in your module
  3. Magento: Access denied in admin of custom module
  4. Magento: Read Write XML
  5. MySQL Installation Problem
  6. Magento: How to get controller, module, action and router name?
  7. Magento: How to change Currency symbol by Model Override ?
  8. Backup and Recovery of MySQL database
  9. Magento: Helper Data not found error
  10. Magento: Fatal error: Call to a member function setSaveParametersInSession() on a non-object
  • 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

  • http://www.facebook.com/people/Shaun-OReilly/100001146114844 Shaun O’Reilly

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

  • http://blog.chapagain.com.np/ Mukesh

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

  • http://blog.chapagain.com.np/ Mukesh

    “core_resource” table