Saturday, July 28, 2012

Magento upgrading the MYSQL SCRIPT for Module

Every Module in Magento have the Sql folder in which all the insert script is written but some time we need to add new field in  some tables so we need to upgrade the script .You don't need to change or run the query directly in databse it's wrong way

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 yourmodule/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 yourmodule/etc/config.xml as well.

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

4) That's it reload the website and refresh the database

Note : But some time new script not get upgraded then you can check in "core_resource" table which will help to identify

2 comments:

  1. Thanks for sharing, what would happend if we run query directly!
    Magento Modules

    ReplyDelete
  2. we can run the Query Directly but we should always used magento standard which will not affect our code.........

    ReplyDelete

Thankyou for your Comments

LinkWithin

Blog has moved, searching new blog...