【问题标题】:Doctrine fails to update schema. "Nothing to update" (Symfony 3.4.8)Doctrine 无法更新架构。 “没什么可更新的”(Symfony 3.4.8)
【发布时间】:2021-06-17 11:30:55
【问题描述】:

我最近使用php bin/console doctorine:generate:entity 创建了一个实体。创建后,我尝试使用php bin/console doctrine:schema:update --force 更新我的架构,但得到以下输出:

Nothing to update - your database is already in sync with the current entity metadata.

我已经尝试过的事情:

  • php bin/console doctrine:schema:update --dump-sql

同样的输出

  • php bin/console doctrine:cache:clear-metadata

跑了,但没有任何改变

  • 多次清除缓存

什么都没有

  • php bin/console doctrine:mapping:info

输出: [确定] FOS\UserBundle\Model\Group [确定] FOS\UserBundle\Model\User

相关实体:


namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="WeeklyPaymentReport")
 */
class WeeklyPaymentReport
{
    /**
     * @var int
     * 
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var int
     * 
     * @ORM\Column(type="integer", nullable=true)
     */
    private $bbid;

    /**
     * @var String
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $request;

    /**
     * @var \DateTime
     * 
     * @ORM\Column(name="dateOfBirth", type="date", nullable=true)
     */
    private $date;


    
    public function getId()
    {
        return $this->id;
    }

    
    public function setBbid($bbid)
    {
        $this->bbid = $bbid;

        return $this;
    }

    
    public function getBbid()
    {
        return $this->bbid;
    }

    
    public function setRequest($request)
    {
        $this->request = $request;

        return $this;
    }

    
    public function getRequest()
    {
        return $this->request;
    }

    
    public function setDate($date)
    {
        $this->date = $date;

        return $this;
    }

    
    public function getDate()
    {
        return $this->date;
    }
}

教义也产生了:


namespace AppBundle\Repository;

/**
 * WeeklyPaymentReportRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class WeeklyPaymentReportRepository extends \Doctrine\ORM\EntityRepository
{
}

还有.orm.php:


use Doctrine\ORM\Mapping\ClassMetadataInfo;

$metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE);
$metadata->customRepositoryClassName = 'AppBundle\Repository\WeeklyPaymentReportRepository';
$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT);
$metadata->mapField(array(
   'fieldName' => 'id',
   'type' => 'integer',
   'id' => true,
   'columnName' => 'id',
  ));
$metadata->mapField(array(
   'columnName' => 'bbid',
   'fieldName' => 'bbid',
   'type' => 'integer',
  ));
$metadata->mapField(array(
   'columnName' => 'request',
   'fieldName' => 'request',
   'type' => 'string',
   'length' => 255,
  ));
$metadata->mapField(array(
   'columnName' => 'date',
   'fieldName' => 'date',
   'type' => 'datetime',
  ));
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); 

我还能尝试什么?

提前感谢您的帮助!

【问题讨论】:

    标签: php symfony doctrine-orm doctrine


    【解决方案1】:

    好的,所以在发布之后,我找到了一个我以前从未被推荐过的post,它解决了这个问题。

    最后一句话,解决了我的问题。

    “删除 John.orm.php 文件后,如果我运行 php bin/console dictionary:schema:update --force 那么它将生成表。”

    有点诡异的解决方案,希望以后的开发不要因此而遇到诡异的异常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-22
      • 2014-12-15
      • 1970-01-01
      • 2023-02-18
      相关资源
      最近更新 更多