0

I have created file mysql4-upgrade-1.6.0.1-1.6.0.2 in which code is like,

<?php
$installer = $this;
$installer->startSetup();
$installer->getConnection()
->addColumn($installer->getTable('newsletter_subscriber'),'subscriber_name', array(
 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
 'length' => 255,
 'after' => 'subscriber_email', // column name to insert new column after
 'comment' => 'Subscriber Name'
 )); 
$installer->endSetup();
?>

Also changed in config file. It is like,

<modules>
 <Mage_Newsletter>
 <version>1.6.0.2</version>
 </Mage_Newsletter>
</modules>

But still column is not added in the database 'newsletter_subscriber' table. Any help?

asked Nov 25, 2016 at 11:25
5
  • Don't edit Magento core files directly; Have a look there, it tells you how to create setup files for custom modules: inchoo.net/magento/… Commented Nov 25, 2016 at 11:27
  • Is there any way if I want to upgrade core file and core module for this? @Mayers Commented Nov 25, 2016 at 11:37
  • you need to create a custom module, and in the setup file of this custom module you can modify core tables. The only reason for this, is that a Magento upgrade would wipe your changes (The link above gives you a detailed tutorial about how to create this module) Commented Nov 25, 2016 at 11:44
  • Thank you dear! I tried your words and it works. @Mayers Commented Nov 25, 2016 at 11:59
  • great news! I have added my comment as a response, if it's helped you, please mark it as accepted so we can close off this post Commented Nov 25, 2016 at 15:12

3 Answers 3

1

If above syntax is not working for you then you can try below syntax to

<?php
$installer = $this;
$installer->startSetup();
try {
 $tableName = $installer->getTable('newsletter_subscriber');
 $installer->run(" ALTER TABLE {$tableName} ADD `subscriber_email` VARCHAR(255) NOT NULL ; ");
 $installer->endSetup();
} catch (Exception $e) {
 // to do
}

and also check your core_resource table if entry is already there for your new version then revert and try again

answered Nov 25, 2016 at 12:22
1

Try this :

<?php
$installer = $this;
$installer->startSetup();
$installer->getConnection()
->addColumn($installer->getTable('newsletter/subscriber'),
'subscriber_name', 
array(
 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
 'length' => 255,
 'after' => 'subscriber_email', // column name to insert new column after
 'comment' => 'Subscriber Name'
 )); 
$installer->endSetup();
?> 
answered Nov 25, 2016 at 13:32
0

Don't edit Magento core files directly; Have a look there, it tells you how to create setup files for custom modules: http://inchoo.net/magento/magento-install-install-upgrade-data-and-data-upgrade-scripts/

You need to create a custom module, and in the setup file of this custom module you can modify core tables. The only reason for this, is that a Magento upgrade would wipe your changes (The link above gives you a detailed tutorial about how to create this module)

answered Nov 25, 2016 at 15:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.