Doctrine 无法更新模式。 "Nothing to update" (Symfony 3.4.8)
Doctrine fails to update schema. "Nothing to update" (Symfony 3.4.8)
我最近用 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);
我还能尝试什么?
提前感谢您的帮助!
好的,所以在发布后,我发现了一个 我以前从未被推荐过的解决了问题。
最后一句话解决了我的问题。
"删除 John.orm.php 文件后 if i 运行 php bin/console doctrine:schema:update --force 然后它会生成表格。"
有点奇怪的解决方案,希望以后的开发不要因此而遇到奇怪的异常。
我最近用 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);
我还能尝试什么?
提前感谢您的帮助!
好的,所以在发布后,我发现了一个
最后一句话解决了我的问题。
"删除 John.orm.php 文件后 if i 运行 php bin/console doctrine:schema:update --force 然后它会生成表格。"
有点奇怪的解决方案,希望以后的开发不要因此而遇到奇怪的异常。