2017-11-02 14 views
1

私はDoctrineの初心者ですが、私はこれを行うときにこの奇妙なエラーがあります。doctrine:schema:updateテーブルが見つかりましたが、テーブルを更新しません

PHPアプリ/コンソール教義:スキーマ:更新--dump-SQL

[Doctrine\DBAL\Schema\SchemaException]         
    The table with name 'akeneo_db01.pim_catalog_family' already exists. 

これは、我々はリソースの教義ディレクトリに持っているコードです。

Iclei\Bundle\BackendBundle\Entity\Family: 
type: entity 
table: pim_catalog_family 
changeTrackingPolicy: DEFERRED_EXPLICIT 
repositoryClass: Akeneo\Bundle\ClassificationBundle\Doctrine\ORM\Repository\CategoryRepository 
uniqueConstraints: 
    pim_category_code_uc: 
     columns: 
      - code 
fields: 
    templateCode: 
     type: text 
     nullable: true 

あなたが見ることができるように私はpim_catalog_familyにフィールドtemplateCodeを追加しようとしているとcertanly私は私が間違って何をやっているだけ平野ゲッターとセッター

でエンティティディレクトリにそれを得ましたか?

編集:これは私たちのFamily.phpエンティティ

<?php 
/** 
* Created by PhpStorm. 
* User: nebo 
* Date: 2.11.17. 
* Time: 10.50 
*/ 

namespace Iclei\Bundle\BackendBundle\Entity; 

use Pim\Bundle\CatalogBundle\Entity\Family as BaseFamily; 

class Family extends BaseFamily 
{ 
    protected $templateCode; 

    /** 
    * @return mixed 
    */ 
    public function getTemplateCode() 
    { 
     return $this->templateCode; 
    } 

    /** 
    * @param mixed $templateCode 
    */ 
    public function setTemplateCode($templateCode) 
    { 
     $this->templateCode = $templateCode; 
    } 
} 

であり、これは私が更新しようとしているものです:

<?php 

namespace Pim\Bundle\CatalogBundle\Entity; 

use Akeneo\Component\Localization\Model\TranslationInterface; 
use Doctrine\Common\Collections\ArrayCollection; 
use Pim\Component\Catalog\AttributeTypes; 
use Pim\Component\Catalog\Model\AttributeInterface; 
use Pim\Component\Catalog\Model\AttributeRequirementInterface; 
use Pim\Component\Catalog\Model\FamilyInterface; 

/** 
* Family entity 
* 
* @author Filips Alpe <[email protected]> 
* @copyright 2013 Akeneo SAS (http://www.akeneo.com) 
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 
*/ 
class Family implements FamilyInterface 
{ 
    /** 
    * @var int 
    */ 
    protected $id; 

    /** 
    * @var string 
    */ 
    protected $code; 

    /** 
    * @var \Doctrine\Common\Collections\ArrayCollection 
    */ 
    protected $attributes; 

    /** 
    * Used locale to override Translation listener's locale 
    * this is not a mapped field of entity metadata, just a simple property 
    * 
    * @var string 
    */ 
    protected $locale; 

    /** 
    * @var \Doctrine\Common\Collections\ArrayCollection 
    */ 
    protected $translations; 

    /** 
    * @var AttributeInterface 
    */ 
    protected $attributeAsLabel; 

    /** 
    * @var \Doctrine\Common\Collections\ArrayCollection 
    */ 
    protected $requirements; 

    /** 
    * @var \DateTime 
    */ 
    protected $created; 

    /** 
    * @var \DateTime 
    */ 
    protected $updated; 

    /** 
    * Constructor 
    */ 
    public function __construct() 
    { 
     $this->attributes = new ArrayCollection(); 
     $this->translations = new ArrayCollection(); 
     $this->requirements = new ArrayCollection(); 
    } 

    /** 
    * Returns the label of the family 
    * 
    * @return string 
    */ 
    public function __toString() 
    { 
     return $this->getLabel(); 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 

    /** 
    * Get created datetime 
    * 
    * @return \DateTime 
    */ 
    public function getCreated() 
    { 
     return $this->created; 
    } 

    /** 
    * Set created datetime 
    * 
    * @param \DateTime $created 
    * 
    * @return Family 
    */ 
    public function setCreated($created) 
    { 
     $this->created = $created; 

     return $this; 
    } 

    /** 
    * Get updated datetime 
    * 
    * @return \DateTime 
    */ 
    public function getUpdated() 
    { 
     return $this->updated; 
    } 

    /** 
    * Set updated datetime 
    * 
    * @param \DateTime $updated 
    * 
    * @return Family 
    */ 
    public function setUpdated($updated) 
    { 
     $this->updated = $updated; 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getCode() 
    { 
     return $this->code; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function setCode($code) 
    { 
     $this->code = $code; 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function addAttribute(AttributeInterface $attribute) 
    { 
     if (!$this->attributes->contains($attribute)) { 
      $this->attributes->add($attribute); 
     } 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function removeAttribute(AttributeInterface $attribute) 
    { 
     if (AttributeTypes::IDENTIFIER === $attribute->getType()) { 
      throw new \InvalidArgumentException('Identifier cannot be removed from a family.'); 
     } 

     $this->attributes->removeElement($attribute); 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getAttributes() 
    { 
     return $this->attributes; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getAttributeCodes() 
    { 
     $codes = []; 
     foreach ($this->attributes as $attribute) { 
      $codes[] = $attribute->getCode(); 
     } 

     return $codes; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getGroupedAttributes() 
    { 
     $result = []; 
     foreach ($this->attributes as $attribute) { 
      $result[(string) $attribute->getGroup()][] = $attribute; 
     } 

     return $result; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function hasAttribute(AttributeInterface $attribute) 
    { 
     return $this->attributes->contains($attribute); 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function hasAttributeCode($attributeCode) 
    { 
     return in_array($attributeCode, $this->getAttributeCodes()); 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function setAttributeAsLabel(AttributeInterface $attributeAsLabel) 
    { 
     $this->attributeAsLabel = $attributeAsLabel; 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getAttributeAsLabel() 
    { 
     return $this->attributeAsLabel; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getAttributeAsLabelChoices() 
    { 
     return $this->attributes->filter(
      function ($attribute) { 
       return in_array(
        $attribute->getType(), 
        [AttributeTypes::TEXT, AttributeTypes::IDENTIFIER] 
       ); 
      } 
     )->toArray(); 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function setLocale($locale) 
    { 
     $this->locale = $locale; 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getTranslations() 
    { 
     return $this->translations; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getTranslation($locale = null) 
    { 
     $locale = ($locale) ? $locale : $this->locale; 
     if (null === $locale) { 
      return null; 
     } 
     foreach ($this->getTranslations() as $translation) { 
      if ($translation->getLocale() == $locale) { 
       return $translation; 
      } 
     } 

     $translationClass = $this->getTranslationFQCN(); 
     $translation = new $translationClass(); 
     $translation->setLocale($locale); 
     $translation->setForeignKey($this); 
     $this->addTranslation($translation); 

     return $translation; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function addTranslation(TranslationInterface $translation) 
    { 
     if (!$this->translations->contains($translation)) { 
      $this->translations->add($translation); 
     } 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function removeTranslation(TranslationInterface $translation) 
    { 
     $this->translations->removeElement($translation); 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getTranslationFQCN() 
    { 
     return 'Pim\Bundle\CatalogBundle\Entity\FamilyTranslation'; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getLabel() 
    { 
     $translated = $this->getTranslation() ? $this->getTranslation()->getLabel() : null; 

     return ($translated !== '' && $translated !== null) ? $translated : '['.$this->getCode().']'; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function setLabel($label) 
    { 
     $this->getTranslation()->setLabel($label); 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function addAttributeRequirement(AttributeRequirementInterface $requirement) 
    { 
     $requirementKey = $this->getAttributeRequirementKey($requirement); 
     $requirements = $this->getAttributeRequirements(); 

     if (!isset($requirements[$requirementKey])) { 
      $requirement->setFamily($this); 
      $this->requirements->add($requirement); 
     } else { 
      $requirements[$requirementKey]->setRequired($requirement->isRequired()); 
     } 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function removeAttributeRequirement(AttributeRequirementInterface $requirement) 
    { 
     $this->requirements->removeElement($requirement); 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function setAttributeRequirements(array $requirements) 
    { 
     foreach ($requirements as $requirement) { 
      $requirement->setFamily($this); 
     } 
     $this->requirements = new ArrayCollection($requirements); 

     return $this; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getAttributeRequirements() 
    { 
     $result = []; 

     foreach ($this->requirements as $requirement) { 
      $key = $this->getAttributeRequirementKey($requirement); 
      $result[$key] = $requirement; 
     } 

     return $result; 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getAttributeRequirementKey(AttributeRequirementInterface $requirement) 
    { 
     return sprintf(
      '%s_%s', 
      $requirement->getAttributeCode(), 
      $requirement->getChannelCode() 
     ); 
    } 

    /** 
    * {@inheritdoc} 
    */ 
    public function getReference() 
    { 
     return $this->code; 
    } 
} 

答えて

0

uniqueConstraints定義が存在しないcodeフィールドが含まれています。 templateCode

+0

助けをお寄せいただきありがとうございます。しかし、わかりません。コードフィールドはPim \ Bundle | CatalogBu​​ndle \ Entity \ Familyにあります。 – FortuneSoldier

+0

マッピングファイルに存在しますか?マッピングファイル全体を配置できますか?関係が誤って定義されていることもあります。 – Asha

+0

質問を編集しました。 – FortuneSoldier

1

これは、symfonyの設定(app/config/config.yml)ファイルに追加する必要があるためです。

akeneo_storage_utils: 
    mapping_overrides: 
      - 
      original: Pim\Bundle\CatalogBundle\Entity\Family 
      override: Iclei\Bundle\BackendBundle\Entity\Family 
関連する問題