我正在使用Skipper ORM设计/生成实体 - 一切都输出正常 - 然后我做:
app/console doctrine:database:drop --force
app/console doctrine:database:create
app/console doctrine:schema:update --force
app/console doctrine:generate:entities --no-backup MyNamespace/MyBundle
我收到错误/异常:
[学说\ DBAL \架构\ SchemaException]
没有列名称' alternateId'在表格'库存'。
是什么给出的?有问题的实体肯定有这个领域:
<?php
namespace Company\DistributionBundle\Entity;
use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Entity(repositoryClass="Company\DistributionBundle\Repository\InventoryRepository")
* @ORM\Table(
* name="inventory",
* indexes={@ORM\Index(name="ALTID", columns={"alternateId"})},
* uniqueConstraints={
* @ORM\UniqueConstraint(name="PKID", columns={"id"}),
* @ORM\UniqueConstraint(name="FINDID", columns={"partNumber","partDescription"})
* }
* )
*/
class Inventory
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private $alternateId;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private $unitOftMeasure;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private $minimumQuantity;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private $maximumQuantity;
/**
* @ORM\Column(type="decimal", nullable=false)
*/
private $maximumCycles;
/**
* @ORM\Column(type="decimal", nullable=false, precision=10, scale=4)
*/
private $maximumTime;
/**
* @ORM\Column(type="decimal", nullable=false, precision=10, scale=2)
*/
private $listPrice;
/**
* @ORM\Column(type="date", nullable=false)
*/
private $datePrice;
/**
* @ORM\Column(type="string", length=50, nullable=false)
*/
private $partNumber;
/**
* @ORM\Column(type="string", length=50, nullable=false)
*/
private $partDescription;
/**
* @ORM\Column(type="text", length=255, nullable=true)
*/
private $partNotes;
/**
* @ORM\OneToOne(targetEntity="Company\DistributionBundle\Entity\Application", inversedBy="inventory")
* @ORM\JoinColumn(name="application_id", referencedColumnName="id", nullable=false, unique=true)
*/
private $application;
/**
* @ORM\OneToOne(targetEntity="Company\DistributionBundle\Entity\Category", inversedBy="inventory")
* @ORM\JoinColumn(name="category_id", referencedColumnName="id", nullable=false, unique=true)
*/
private $category;
/**
* @ORM\OneToOne(targetEntity="Company\DistributionBundle\Entity\Manufacturer", inversedBy="inventory")
* @ORM\JoinColumn(name="manufacturer_id", referencedColumnName="id", nullable=false, unique=true)
*/
private $manufacturer;
/**
* @ORM\ManyToMany(targetEntity="Company\DistributionBundle\Entity\InventoryOptions", mappedBy="inventory")
*/
private $inventoryOptions;
}
答案 0 :(得分:1)
尝试使用doctrine migrations bundle有两个原因:
此外,它了解您的实体,阅读注释并创建所需的文件。
继续探索它。