While writing codes for Magento, sometimes you would like to add new columns to existing tables in Magento database. These situations arise very frequently in Magento programming. Suppose you want to add a custom ‘referred_by’ column to the items in your wishlist. Magento stores the wishlist items in the ‘wishlist_item’ table. So here we will add ‘referred_by’ column to the table. This column will store the id of the customer who referred a certain product. Now we will see how to add this column to existing ‘wishlist_item’ table. For this you have to create a custom module . Suppose you have created your module ‘Web’ under ‘Company’ namespace. In the sql installer file for this module, we will write the code to add the new column.
Write following lines in this file: