-1

我在magento中有一个扩展,安装后可以正常工作,但是当我通过删除数据库中的core_resource来重置/重新启动扩展时(因为我添加了更多属性,仅在重新加载扩展时才显示的功能)我已经使用了之前的技术用于另一个模块并且工作正常但是这个扩展给了我一个错误

所以我在整个网站上遇到了巨大的错误,所以我检查了 var/report,它说扩展的安装文件中有错误(因为它试图重新加载安装文件,但它必须与创建有关或覆盖第一次创建但未在数据库中删除的表,因为它们应该保留,因为它是已保存的数据,删除这些表将导致再次输入数据

所以请参阅下面似乎导致问题的安装文件

<?php

$installer = $this;
/* @var $installer Mage_Core_Model_Resource_Setup */

$installer->startSetup();
$installer->run("
CREATE TABLE IF NOT EXISTS `customerpartner_aux` (
  `id` INT(11)  NOT NULL AUTO_INCREMENT,
  `product_id` INT(11)  NOT NULL,
  `order_id` INT(11)  NOT NULL,
  `real_order_id` INT(11)  NOT NULL,
  `quantity` INT(11)  NOT NULL,
  `percent` DECIMAL(10,2)  NOT NULL,
  `amount_earned` DECIMAL(10,2)  NOT NULL,
  `amount_owed` DECIMAL(10,2)  NOT NULL,
  `cleared_at` DATETIME NOT NULL,
  PRIMARY KEY (`id`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{$this->getTable('customerpartner_entity')}` (
  `entity_id` int(10) unsigned NOT NULL auto_increment,
  `entity_type_id` smallint(8) unsigned NOT NULL default '0',
  `attribute_set_id` smallint(5) unsigned NOT NULL default '0',
  `website_id` smallint(5) unsigned default NULL,
  `email` varchar(255) NOT NULL default '',
  `group_id` smallint(3) unsigned NOT NULL default '0',
  `increment_id` varchar(50) NOT NULL default '', `parent_id` int(10) unsigned NOT NULL default '0',
  `store_id` smallint(5) unsigned default '0',
  `created_at` datetime NOT NULL default '0000-00-00 00:00:00',
  `updated_at` datetime NOT NULL default '0000-00-00 00:00:00',
  `is_active` tinyint(1) unsigned NOT NULL default '1',
  PRIMARY KEY  (`entity_id`),
  KEY `FK_CUSTOMERPARTNER_ENTITY_STORE` (`store_id`),
  KEY `IDX_ENTITY_TYPE` (`entity_type_id`),
  KEY `IDX_AUTH` (`email`,`website_id`),
  KEY `FK_CUSTOMERPARTNER_WEBSITE` (`website_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Customer Entityies' AUTO_INCREMENT=1 ;


CREATE TABLE IF NOT EXISTS `{$this->getTable('customerpartner_entity_datetime')}` (
  `value_id` int(11) NOT NULL auto_increment,
  `entity_type_id` smallint(8) unsigned NOT NULL default '0',
  `attribute_id` smallint(5) unsigned NOT NULL default '0',
  `entity_id` int(10) unsigned NOT NULL default '0',
  `value` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`value_id`),
  KEY `FK_CUSTOMERPARTNER_DATETIME_ENTITY_TYPE` (`entity_type_id`),
  KEY `FK_CUSTOMERPARTNER_DATETIME_ATTRIBUTE` (`attribute_id`),
  KEY `FK_CUSTOMERPARTNER_DATETIME_ENTITY` (`entity_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


CREATE TABLE IF NOT EXISTS `{$this->getTable('customerpartner_entity_decimal')}` (
  `value_id` int(11) NOT NULL auto_increment,
  `entity_type_id` smallint(8) unsigned NOT NULL default '0',
  `attribute_id` smallint(5) unsigned NOT NULL default '0',
  `entity_id` int(10) unsigned NOT NULL default '0',
  `value` decimal(12,4) NOT NULL default '0.0000',
  PRIMARY KEY  (`value_id`),
  KEY `FK_CUSTOMERPARTNER_DECIMAL_ENTITY_TYPE` (`entity_type_id`),
  KEY `FK_CUSTOMERPARTNER_DECIMAL_ATTRIBUTE` (`attribute_id`),
  KEY `FK_CUSTOMERPARTNER_DECIMAL_ENTITY` (`entity_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


CREATE TABLE IF NOT EXISTS `{$this->getTable('customerpartner_entity_int')}` (
  `value_id` int(11) NOT NULL auto_increment,
  `entity_type_id` smallint(8) unsigned NOT NULL default '0',
  `attribute_id` smallint(5) unsigned NOT NULL default '0',
  `entity_id` int(10) unsigned NOT NULL default '0',
  `value` int(11) NOT NULL default '0',
  PRIMARY KEY  (`value_id`),
  KEY `FK_CUSTOMERPARTNER_INT_ENTITY_TYPE` (`entity_type_id`),
  KEY `FK_CUSTOMERPARTNER_INT_ATTRIBUTE` (`attribute_id`),
  KEY `FK_CUSTOMERPARTNER_INT_ENTITY` (`entity_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


CREATE TABLE IF NOT EXISTS `{$this->getTable('customerpartner_entity_text')}` (
  `value_id` int(11) NOT NULL auto_increment,
  `entity_type_id` smallint(8) unsigned NOT NULL default '0',
  `attribute_id` smallint(5) unsigned NOT NULL default '0',
  `entity_id` int(10) unsigned NOT NULL default '0',
  `value` text NOT NULL,
  PRIMARY KEY  (`value_id`),
  KEY `FK_CUSTOMERPARTNER_TEXT_ENTITY_TYPE` (`entity_type_id`),
  KEY `FK_CUSTOMERPARTNER_TEXT_ATTRIBUTE` (`attribute_id`),
  KEY `FK_CUSTOMERPARTNER_TEXT_ENTITY` (`entity_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


CREATE TABLE IF NOT EXISTS `{$this->getTable('customerpartner_entity_varchar')}` (
  `value_id` int(11) NOT NULL auto_increment,
  `entity_type_id` smallint(8) unsigned NOT NULL default '0',
  `attribute_id` smallint(5) unsigned NOT NULL default '0',
  `entity_id` int(10) unsigned NOT NULL default '0',
  `value` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`value_id`),
  KEY `FK_CUSTOMERPARTNER_VARCHAR_ENTITY_TYPE` (`entity_type_id`),
  KEY `FK_CUSTOMERPARTNER_VARCHAR_ATTRIBUTE` (`attribute_id`),
  KEY `FK_CUSTOMERPARTNER_VARCHAR_ENTITY` (`entity_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


ALTER TABLE `{$this->getTable('customerpartner_entity')}`
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_ENTITY_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_WEBSITE` FOREIGN KEY (`website_id`) REFERENCES `{$this->getTable('core_website')}` (`website_id`) ON DELETE SET NULL ON UPDATE CASCADE;


ALTER TABLE `{$this->getTable('customerpartner_entity_datetime')}`
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_DATETIME_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$this->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_DATETIME_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$this->getTable('customerpartner_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_DATETIME_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE;

ALTER TABLE `{$this->getTable('customerpartner_entity_decimal')}`
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_DECIMAL_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$this->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_DECIMAL_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$this->getTable('customerpartner_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_DECIMAL_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE;

ALTER TABLE `{$this->getTable('customerpartner_entity_int')}`
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_INT_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$this->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_INT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$this->getTable('customerpartner_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_INT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE;

ALTER TABLE `{$this->getTable('customerpartner_entity_text')}`
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_TEXT_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$this->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_TEXT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$this->getTable('customerpartner_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_TEXT_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE;

ALTER TABLE `{$this->getTable('customerpartner_entity_varchar')}`
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_VARCHAR_ATTRIBUTE` FOREIGN KEY (`attribute_id`) REFERENCES `{$this->getTable('eav_attribute')}` (`attribute_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_VARCHAR_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `{$this->getTable('customerpartner_entity')}` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `FK_CUSTOMERPARTNER_VARCHAR_ENTITY_TYPE` FOREIGN KEY (`entity_type_id`) REFERENCES `{$this->getTable('eav_entity_type')}` (`entity_type_id`) ON DELETE CASCADE ON UPDATE CASCADE;
    ");

$installer->installEntities();

$installer->endSetup();  

所以任何帮助将不胜感激,因为这是一个开源社区项目,在我能够随时重置/重新加载扩展程序(以轻松添加属性等)之前真的不能再进一步了,而不必删除每个表和数据库中的实体导致用户输入的所有数据丢失,随着时间的推移,这将是巨大的。

我也将尝试调试它直到它修复

干杯

nz战士

4

1 回答 1

1

当您从 core_resource 中删除模块名称时,下次加载站点时它将尝试创建数据库,因为 magento 认为该模块确实存在(并且您将收到站点错误)。您可以做的是创建更新(更改该模块的版本号)

请参阅Magento 安装脚本和升级脚本

于 2012-11-03T04:27:50.583 回答