s47c953
s47c953

Reputation: 3

Doctrine Migrations doesn't find generated version

I am trying to fill a database with tables, but I cant migrate to it after generating it.

I am using Zend Framework 3 and added doctrine-orm-module and migrations with the composer.phar file. Strangely enough generating a new version works without problems. I'm executing the command like this:

./vendor/bin/doctrine-module migrations:generate

The new, empty version file appears in the folder I supplied, no problem. But when I want to migrate to it with

./vendor/bin/doctrine-module migrations:migrate

I get the error:

In NoMigrationsToExecute.php line 13:

  Could not find any migrations to execute. 

Similar if I try execute:

./vendor/bin/doctrine-module migrations:execute 20191003105717

Error:

In UnknownMigrationVersion.php line 14:

  Could not find migration version 20191003105717  

I'm using php7.3, MariaDb, and the code is in a vagrant box.

config\autoload\global.php

<?php

use Doctrine\DBAL\Driver\PDOMySql\Driver as PDOMySqlDriver;

return [
    'doctrine' => [
        'connection' => [
            'orm_default' => [
                'driverClass' => PDOMySqlDriver::class,
                'params' => [
                    'host'     => 'localhost',
                    'user'     => 'user',
                    'password' => 'pw',
                    'dbname'   => 'myDB',
                ]
            ],
        ],
        'migrations_configuration' => [
            'orm_default' => [
                'directory' => 'data/Migrations',
                'name'      => 'Doctrine Database Migrations',
                'namespace' => 'Migrations',
                'table'     => 'migrations',
            ],
        ],
    ],
];

I configured this according to these two tutorial chapters:
Database Management with Doctrine ORM
Database Migrations

Thanks for any help!

Edit: Here is the output with full verbosity on:

./vendor/bin/doctrine-module migrations:migrate -vvv

                    Doctrine Database Migrations                    


WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue? (y/n)y
Migrating up to 0 from 0

In NoMigrationsToExecute.php line 13:

  [Doctrine\Migrations\Exception\NoMigrationsToExecute (4)]  
  Could not find any migrations to execute.                  


Exception trace:
  at /vagrant_data/vendor/doctrine/migrations/lib/Doctrine/Migrations/Exception/NoMigrationsToExecute.php:13
 Doctrine\Migrations\Exception\NoMigrationsToExecute::new() at /vagrant_data/vendor/doctrine/migrations/lib/Doctrine/Migrations/Migrator.php:137
 Doctrine\Migrations\Migrator->migrate() at /vagrant_data/vendor/doctrine/migrations/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php:162
 Doctrine\Migrations\Tools\Console\Command\MigrateCommand->execute() at /vagrant_data/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /vagrant_data/vendor/symfony/console/Application.php:915
 Symfony\Component\Console\Application->doRunCommand() at /vagrant_data/vendor/symfony/console/Application.php:272
 Symfony\Component\Console\Application->doRun() at /vagrant_data/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /vagrant_data/vendor/doctrine/doctrine-module/bin/doctrine-module.php:45
 include() at /vagrant_data/vendor/doctrine/doctrine-module/bin/doctrine-module:4

migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--all-or-nothing [ALL-OR-NOTHING]] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--object-manager [OBJECT-MANAGER]] [--] [<version>]

It does not seem to be a Migrations problem, but where could the error be then?

Upvotes: 0

Views: 4035

Answers (1)

dominic detta
dominic detta

Reputation: 221

I had the same problem and I solved modifying the migration_namespace with the right one which you can find in the generated version class.

Upvotes: 1

Related Questions