Magento Module Upgrade Modify database table structure

Source: Internet
Author: User
Tags naming convention

Magento supports creating, deleting, and updating database tables and fields in the module. In this way, adding and modifying fields becomes a very easy task in the process of plug-in development. Just modify the version number of the module and add a script that conforms to the naming convention in the file.

If the current Magento module is ruiwant_rewards and the version number is 0.9.0, we would like to add a status field for the integration table in this module. First step, we need to change the version number to 0.9.1. The data-upgrade-0.9.0-0.9.1.php file is then created in the root directory of the module (based on the directory you have been using, in this case, the data directory). Data/sql In the file, add the following code.

$installer = $ This; $table= $installergetconnection ()->addcolumn ($installer->gettable ('Rewards/point'),'Status', Varien_db_ddl_table::type_smallint,NULL, Array ('unsigned'=true,        'Nullable'=true,    ), 'Point Status'); $installer->endsetup ();

If everything works, the table will successfully add a status field. Similar to AddColumn () more Magento Package database table structure modification method can refer to the article or directly to the source inside to see.

Magento Module Upgrade Modify database table structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.