getConnection('rewardpoints_read'); $select = $connection->select() ->from('information_schema.COLUMNS') ->where("COLUMN_NAME='date_start' AND TABLE_NAME='{$this->getTable('rewardpoints_account')}'"); $data = $connection->fetchRow($select); if(!isset($data['COLUMN_NAME'])){ $sqls[] = "ALTER TABLE {$this->getTable('rewardpoints_account')} ADD COLUMN `date_start` DATE NULL DEFAULT NULL AFTER `points_spent` , ADD `date_end` DATE NULL DEFAULT NULL AFTER `date_start`;"; //$installer = $this; /* @var $installer Mage_Core_Model_Resource_Setup */ /* $installer->startSetup(); $installer->run(" ALTER TABLE {$this->getTable('rewardpoints_account')} ADD COLUMN `date_start` DATE NULL DEFAULT NULL AFTER `points_spent` , ADD `date_end` DATE NULL DEFAULT NULL AFTER `date_start`; "); $installer->endSetup(); */ } /* SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME='store_id' AND DATA_TYPE='text' AND table_name = 'rewardpoints_account' */ $select = $connection->select() ->from('information_schema.COLUMNS') ->where("COLUMN_NAME='store_id' AND TABLE_NAME='{$this->getTable('rewardpoints_account')}'"); $data = $connection->fetchRow($select); if(!isset($data['COLUMN_NAME'])){ $sqls[] = "ALTER TABLE {$this->getTable('rewardpoints_account')} DROP INDEX FK_catalog_category_ENTITY_STORE;"; $sqls[] = "ALTER TABLE {$this->getTable('rewardpoints_account')} CHANGE `store_id` `store_id` TEXT NULL DEFAULT NULL;"; } if ($sqls != array()){ $installer = $this; $installer->run(implode(' ',$sqls)); $installer->endSetup(); }