Skip to content

make:migration runs indefinitely #643

@hunomina

Description

@hunomina

I recently updated my project (Symfony 4.4, PHP7.4) doctrine/migrations dependency from v2.2 to v3.0 and changed in the process my migrations namespace from DoctrineMigrations (default) to App\Migrations.

Configuration before :

doctrine_migrations:
    dir_name: '%kernel.project_dir%/src/Migrations'
    namespace: DoctrineMigrations

After :

doctrine_migrations:
    migrations_paths:
        'App\Migrations': '%kernel.project_dir%/src/Migrations'

Doing so, all my migration versions changed from <timestamp> to App\Migrations\Version<timestamp> affecting the representation of the migrations in the database (column version of the migrations table).

Now if I try to execute the command php bin/console make:migration it runs indefinitely.

In order to build the migration script, it tries to resolve the previously executed ones stored in the database but can't find them in the project based on their new version name (<timestamp> to App\Migrations\Version<timestamp>). And so it runs indefinitely.

I ran the php bin/console doctrine:migrations:diff command (as suggested by @weaverryan) and it gives me the following output (everything seems ok at this point) :

image

On the screenshot, the "1 previously executed migrations in the database that are not registered migrations" refers to the one created and applied before the dependency and configuration update (with the version formatted as <timestamp>) which is not "recognized" by the migration bundle as a registered migration.

And the "1 available migration" refers to the same migration created before the dependency and configuration update considered as "not applied" because its version is different from the one in the database.

Wouldn't it be better to just throw an exception in the console rather than running the command indefinitely if a previous migration can not be found in the current project ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions