开发者

How To Recreate A Table In Magento

开发者 https://www.devze.com 2023-04-11 23:23 出处:网络
I dropped a table manually in magento. Now I want my code to recreate the same table.. I Have written the create statement in app/code/local/namespace/my_module/sql folder like this

I dropped a table manually in magento. Now I want my code to recreate the same table.. I Have written the create statement in app/code/local/namespace/my_module/sql folder like this

DROP TABLE IF EXISTS {$this->getTable('cod')};
CREATE TABLE {$this->getTable('cod')} (
    `cod_id` int(11) unsigned NOT NULL auto_increment,
    `status` smallint(6) NOT NULL default '0',
    'amount' int(11) unsigned NOT NULL,
    `created_time` datetime NULL,
    `update_time` datetime NULL,
    PRIMARY KEY (`cod_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
开发者_运维知识库

How will this query execute so that it can recreate the table...


This query is executed when you run magento with your module first time. After this magento adds row to core_resource table my_module_setup | 0.01 | 0.01 which means, your module was set up successfully. So, to recreate table you should drop row my_module_setup from core_resource table and run any magento page again. Please note, version & data_version columns let you hold module's version up to date. If you change module's version in config.xml to higher than it is in core_resource, magento will look for mysql4-upgrade-0.1.0-0.1.1.php.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号