3

I'm trying to update my custom module's database table.

An so far i have done this.

Created mysql4-upgrade-0.1.0-0.1.1 - With the following code

<?php 
$installer = $this;
$connection = $installer->getConnection();
//do this for each column you want to add
$connection->addColumn($installer->getTable('emailorder'), 'number_of_entries', array(
        'type'      => Varien_Db_Ddl_Table::TYPE_INTEGER,
        'nullable' => false,
        'comment'   => 'Number Of Entries',
    ));

Ive change the vertionsnumber in the module config.xml and in the etc/module folder

Still it doesn't update my database table. What to do?

5
  • What's the value corresponding to your module in core_resource table ? Commented Feb 15, 2016 at 11:33
  • The Veriation number? Or what? Commented Feb 15, 2016 at 11:35
  • Both version and data_version values ? Commented Feb 15, 2016 at 11:36
  • Not sure what you mean, but its 0.1.1 Commented Feb 15, 2016 at 11:37
  • 1
    That means your script ran fine the first time you tried, please update your upgrade script to the one Amit posted and change both data_version and version to 0.1.1 for your module entry under the core_resource table. That will force the upgrade script to run again Commented Feb 15, 2016 at 11:39

1 Answer 1

1

$installer->getTable('emailorder') is wrong.

It format is should be

$installer->getTable('ModulePrefix/Entity)

Or instead of $installer->getTable('emailorder') use the table name

4
  • I have tried this with no result :( $installer->getTable('puk/emailorder'), and ive tried to replace it alle with the tablename. Commented Feb 15, 2016 at 11:06
  • $installer->getConnection() ->addColumn('YOUR_TABLENAME', 'number_of_entries', array( 'type' =>Varien_Db_Ddl_Table::TYPE_INTEGER, 'length' => 10, 'nullable' => true, 'default' => null, 'comment' => 'No of Entitie' ));
    – Amit Bera
    Commented Feb 15, 2016 at 11:15
  • try above. check and that
    – Amit Bera
    Commented Feb 15, 2016 at 11:15
  • No good. Can it be something else than the sql code? Commented Feb 15, 2016 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.