Upgrading Symfony from 3 to 4 getting error: "no registered migrations"

402 Views Asked by At

Trying to upgrade a project from Symfony 3.x to 4.4 and running into some issues with the doctrine migrations.

Currently when trying to run migrations I am receiving this error:

[ERROR] The version "latest" couldn't be reached, there are no registered migrations.

When running the following command to print out my doctrine config:

php app/console config:dump-reference doctrine_migrations

It basically gives me the default doctrine migrations config information.

Currently the project does not use Symfony Flex as I'm suspecting that makes a difference on where this config lives within the project. Doctrine config I have inside my config/config.yml file.

doctrine_migrations:
    # A list of namespace/path pairs where to look for migrations.
    migrations_paths:
        # Prototype
        'DoctrineMigrations': '%kernel.project_dir%/src/Migrations'

    # Storage to use for migration status metadata.
    storage:
        # The default metadata storage, implemented as a table in the database.
        table_storage:
            table_name: 'migrations'
            version_column_name:  'version'

Running the doctrine migrate command returns

+------------+----------------------+------------------------------------------------------------------------+
| Configuration                                                                                              |
+------------+----------------------+------------------------------------------------------------------------+
| Storage    | Type                 | Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration |
|            | Table Name           | doctrine_migration_versions                                            |
|            | Column Name          | version                                                                |
|------------------------------------------------------------------------------------------------------------|
| Database   | Driver               | Doctrine\DBAL\Driver\PDO\PgSQL\Driver                                  |
|            | Name                 | api                                                                    |
|------------------------------------------------------------------------------------------------------------|
| Versions   | Previous             | 0                                                                      |
|            | Current              | 0                                                                      |
|            | Next                 | Already at latest version                                              |
|            | Latest               | 0                                                                      |
|------------------------------------------------------------------------------------------------------------|
| Migrations | Executed             | 0                                                                      |
|            | Executed Unavailable | 0                                                                      |
|            | Available            | 0                                                                      |
|            | New                  | 0                                                                      |
+------------+----------------------+------------------------------------------------------------------------+

As you can see the table name etc does not match up with what's inside the config. I believe I'm missing something here to get the migrations to run but can't seem to figure it out

1

There are 1 best solutions below

2
Artem On

There is no config/config.yml file in symfony4 by default. It seems that this file is ignored.

Move your doctrine_migrations: section from config/config.yml to config/packages/doctrine_migrations.yaml file

example