2017-07-10 31 views
1

當我試圖插入一些Symfony的3例外發生在執行SELECT NEXTVAL

An exception occurred while executing 'SELECT NEXTVAL('oficinas_id_seq')':

SQLSTATE[42P01]: Undefined table: 7 ERROR: no existe la relación «oficinas_id_seq» LINE 1: SELECT NEXTVAL('oficinas_id_seq')

我得到這個錯誤這是我的實體

namespace AppBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 

/** 
* Oficinas 
* 
* @ORM\Table(name="oficinas") 
* @ORM\Entity 
*/ 
class Oficinas 
{ 
    /** 
    * @var integer 
    * 
    * @ORM\Column(name="id", type="integer", nullable=false) 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="SEQUENCE") 
    * @ORM\SequenceGenerator(sequenceName="public.oficinas_id_seq", allocationSize=1, initialValue=1) 
    */ 
    private $id; 

    /** 
    * @var string 
    * 
    * @ORM\Column(name="descripcion", type="string", length=100, nullable=false) 
    */ 
    private $descripcion; 

    /** 
    * @var \DateTime 
    * 
    * @ORM\Column(name="tu", type="datetime", nullable=false) 
    */ 
    private $tu; 

    /** 
    * @var \DateTime 
    * 
    * @ORM\Column(name="ts", type="datetime", nullable=false) 
    */ 
    private $ts = 'now()'; 



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

    /** 
    * Set descripcion 
    * 
    * @param string $descripcion 
    * 
    * @return Oficinas 
    */ 
    public function setDescripcion($descripcion) 
    { 
     $this->descripcion = $descripcion; 

     return $this; 
    } 

    /** 
    * Get descripcion 
    * 
    * @return string 
    */ 
    public function getDescripcion() 
    { 
     return $this->descripcion; 
    } 
} 

從來就測試這個學說命令,但沒」 t work

php bin/console doctrine:mapping:import Bundle annotation php bin/console generate:doctrine:entities Bundle php bin/console doctrine:schema:update --force

任何想法?

+0

嘗試運行'學說:架構:diff'然後遷移:'學說:遷移:migrate'。似乎你的桌子還沒有創建\'Oficinas'。猜猜我應該問你是否首先使用doctrine遷移....對不起 –

+0

嗨@AndrewNolan命令教條:schema:diff沒有定義。我首先創建了postgres數據庫,然後將它遷移到symfony –

+0

是的,如果您不使用doctrine遷移,那麼我發佈的任何命令都不會起作用。對不起,如果我做了更多的混淆。 –

回答

0

我只是運行這個命令來查看代碼和數據庫之間的差異

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