Magento1.9 – Fix Upgrade SQL Setup Not Working

databasemagento-1.9sql

I want to add one more column into an existing table, this is my attempt:

My upgrade-1.0.0-1.1.0.php:

 $installer = $this;
 $installer->startSetup();
 $installer->getConnection();
 $installer->getTable('paketid_booking/result');
     ->addColumn(
        'vendor_airway_bill',
        Varien_Db_Ddl_Table::TYPE_TEXT, 255,
        array(),
        'Vendor Airway Bill'
    )
$installer->endSetup();

Set version :

<modules>
    <PaketId_Booking>
        <!-- The version of our module, starting at 1.0.0 -->
        <version>1.1.0</version>
    </PaketId_Booking>
</modules>
<default>
    <paketid_booking>
        <api>
            <email>test@paket.id</email>
            <key>TEST-API-KEY</key>
            <debug>0</debug>
        </api>
    </paketid_booking>
</default>
<global>
    <blocks>
        <paketid_booking>
            <class>PaketId_Booking_Block</class>
        </paketid_booking>
    </blocks>
    <helpers>
        <paketid_booking>
            <class>PaketId_Booking_Helper</class>
        </paketid_booking>
    </helpers>

My config.xml :

    <models>
        <paketid_booking>
            <class>PaketId_Booking_Model</class>
            <resourceModel>paketid_booking_resource</resourceModel>
        </paketid_booking>        

        <paketid_booking_resource>
            <class>PaketId_Booking_Model_Resource</class>
            <entities>
                <result>
                    <table>paketid_booking_result</table>
                </result>
            </entities>
        </paketid_booking_resource>

    </models>
    <resources>
        <paketid_booking_setup>
            <setup>
                <module>PaketId_Booking</module>
            </setup>
        </paketid_booking_setup>
    </resources>
    <events>
        <checkout_type_onepage_save_order_after>
                <paketid_booking>
                    <type>singleton</type>
                    <class>PaketId_Booking_Model_Observer</class>
                    <method>processOrder</method>
                </paketid_booking>
            </observers>
        </checkout_type_onepage_save_order_after>
    </events>
</global>
<adminhtml>
    <layout>
        <updates>
            <paketid_booking>
                <file>paketid_booking.xml</file>
            </paketid_booking>
        </updates>
    </layout>
    <events>
        <core_block_abstract_to_html_after>
            <observers>
                <paketid_booking>
                    <type>singleton</type>
                    <class>PaketId_Booking_Model_Adminhtml_Observer</class>
                    <method>getSalesOrderBookingInfo</method>
                </paketid_booking>
            </observers>
        </core_block_abstract_to_html_after>
    </events>
</adminhtml>

My sql setup folder :

sql folder

What did I do wrong?

Best Answer

  1. Version may already be updated

First of all make sure that the installed version of your module is 1.0.0. Open your SQL and find the table named "core_resource". Search for your module's entry and check "version" and "data_version"

The changes you make in a module take effect the first time you access your site if the cache is disabled, or the first time you refresh your cache if it is enabled.

By the way, be sure to refresh the cache after any change.

  1. config.xml

I would suggest you made the following changes to your config.xml

<resources>
    <paketid_booking_setup>
        <setup>
            <module>PaketId_Booking</module>
        </setup>
        <connection>
           <use>core_setup</use>
        </connection>
    </paketid_booking_setup>
</resources>
Related Topic