Sadiel
Sadiel

Reputation: 1384

Update schema just from yml in Symfony2 with Doctrine

I want to add an item like this just to the src/Acme/AdminBundle/Entity/Artist.orm.yml:

email:
  type: string
  column: email_address
  length: 150

but I'm forced to do the same in the file Acme/AdminBundle/Entity/Artist

/**
 * @var string $email
 */
private $email;

If I don't do it, when I update the schema it shows an error:

php app/console doctrine:schema:update --force

[Doctrine\ORM\Mapping\MappingException]
An error occurred in Acme\AdminBundle\Entity\Artist

[ReflectionException]
Property email does not exist

I generated the Bundle with the yml option at the beginning.

Upvotes: 3

Views: 4792

Answers (2)

Alfonso Jiménez
Alfonso Jiménez

Reputation: 1245

I had the same problem and I managed to solve it.

doctrine:generate:entity generates the .php entity file at "Entity" but it also generates a orm file at "Resources/config/doctrine" which can create conflicts if you modify the .php entity file.

I just deleted the orm files and it works as expected.

Upvotes: 2

Écio Silva
Écio Silva

Reputation: 142

First, generate the entity class file

php app/console doctrine:generate:entities [Your]/[Bundle]/Entity/Artist --path="src/" --no-backup

The "--path" param must be given if there is a new entity to be generated.

Then, update your schema:

php app/console doctrine:schema:update --force

Upvotes: 8

Related Questions