B
B
BonBon Slick2017-12-10 15:55:14
Doctrine ORM
BonBon Slick, 2017-12-10 15:55:14

Doctrine migrations:diff generate new migrations every time?

doctrine:migrations:diff                Generate a migration by comparing your current database to your mapping information.

In theory, it should check the current database and the mapping that is specified in the annotations in my Entity. However, for some reason it generates new migrations to Entity every time. That is, if I have 1 Entity, I already have a migration, nothing has changed in the mapping, then after entering doctrine:migrations:diffthere will be another same new migration. And then, of course, the script doctrine:migrations:migratethrows errors that such fields already exist. For in the first migration there was an insertion of fields, and in the second there is an insertion.
doctrine_migrations:
    dir_name: '%kernel.project_dir%/src/Migrations'
    # namespace is arbitrary but should be different from App\Migrations
    # as migrations classes should NOT be autoloaded
    namespace: App\Migrations

So it will throw an error that there is no such namespace, because it really does not exist.
namespace: DoctrineMigrations\Infrastructure\Migrations

Why does it generate a new migration each time?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Chernyshev, 2017-12-14
@BonBonSlick

Because the first generated migration was not applied. The generator does compare schema and mapping, but it doesn't look at generated but not applied migrations. That is, there must be a doctrine:migrations:migrate between each doctrine:migrations:diff. Or you need to delete unused ones before generation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question