Php – Symfony2: Database schema and entities not updating with changed metadata

doctrinedoctrine-ormPHPsymfonyyaml

I am having trouble updating the schema in Symfony2.

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

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

The import created the orm.yml files in
/src/{name}/{my}bundle/Resources/config/doctrine/metadata/orm/{table}.orm.yml

It was created with no errors.

When I do:

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 this over and over again and the same query appears and I execute it and it tells me it is done, but again it shows that it needs to be done again.

I then have gone to the orm.yml files and changed them drastically, but nothing no new queries appear other than the one that is always there when I do this.

The 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 it still tells me I need to:

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

I have also tried using DoctrineMigrationsBundle and the same query shows up needing done. I migrate; It says the query is done and when I use it again the same query shows up.

Does anybody have any idea how this is happening? I am stuck on this, so any help is greatly appreciated.

Best Answer

As per @Tomasz, above, make sure that your Symfony2 doesn't try to use annotations to setup database instead of yaml.