G
G
gitdev2019-01-02 15:17:13
symfony
gitdev, 2019-01-02 15:17:13

Why does Symfomy 4 give an error when changing the schema via the command line and how to solve this problem?

In symfomy, I created a Many to many relationship, because of it it gives an error when calling the command: php bin/console doctrine:schema:update --force
Relationship in entity agents:

/**
     * Many Realties have Many Agents.
     *
     * @ManyToMany(targetEntity="App\Metrag\AppBundle\Entity\Realty")
     * @JoinTable(name="agent_realties",
     *      joinColumns={@JoinColumn(name="agent_id", referencedColumnName="id", onDelete="CASCADE")},
     *      inverseJoinColumns={@JoinColumn(name="realty_id", referencedColumnName="id", onDelete="CASCADE")}
     * )
     */
    private $realties;

Mistake:
In SchemaException.php line 112:
                                              
  The table with name 'default.agent_realties' already exists.

Addition: the error appears even if you delete the table in the database.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gitdev, 2019-01-02
@gitdev

Found a solution.
It looks like you already have a table named "agent_realties" in that database. Remove this line @ORM\JoinTable(name="agent_realties") and try without it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question