Symfony2: database schema and objects not updating with modified metadata

I'm having problems updating the schema in Symfony2.

I imported the database into Symfony2 using the doctrine and created all the ORM files in YML.

I created all the entities from this metadata, and it worked fine, but if I want to change the database schema using the orm.yml files, it does not update my database or even update the objects when I regenerate them.

Import created orm.yml files in / SRC / {name} / {mine} bundle / Resources / configuration / Doctrine / metadata / ORM / {table} .orm.yml

It was created without errors.

When I do this:

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

it displays:

 ALTER TABLE accounttypes CHANGE description description VARCHAR(45) NOT NULL 

So I:

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

and

 Updating database schema... Database schema updated successfully! "1" queries were executed 

I can do it again and again, and the same request appears, and I execute it, and it tells me that it is done, but again shows that it needs to be done again.

Then I went into the orm.yml files and changed them dramatically, but there were nothing new requests, except for those that are always there when I do this.

File AccountTypes.orm.yml

 Accounttypes: type: entity table: accounttypes fields: description: id: true type: string length: 45 fixed: false nullable: false generator: strategy: IDENTITY lifecycleCallbacks: { } 

Change to this:

 Accounttypes: type: entity table: accounttypes id: id: type: integer generator: { strategy: AUTO } fields: description: id: true type: string length: 50 lifecycleCallbacks: { } 

And I still said:

 ALTER TABLE accounttypes CHANGE description description VARCHAR(45) NOT NULL 

I also tried using the DoctrineMigrationsBundle, and the same query detects the need. I am migrating; It says that the request is being executed, and when I use it again, the same request appears.

Does anyone know how this happens? I am stuck on this, so any help is greatly appreciated.

+4
source share
2 answers

According to @Tomasz above, make sure your Symfony2 is not trying to use annotations to tune the database instead of yaml.

+2
source

I had the same problem.

The reason was: a newly created package has not yet been added to app\config.yml .

Therefore, all entities in this new package were never exported using php app/console doctrine:schema:update --dump-sql

0
source

Source: https://habr.com/ru/post/1413245/


All Articles