教义迁移找不到生成的版本

时间:2019-10-03 15:28:56

标签: zend-framework3 php-7.3 doctrine-migrations

我试图用表填充数据库,但是生成数据库后无法迁移到数据库。

我正在使用Zend Framework 3,并使用composer.phar文件添加了doctrine-orm-module和迁移。 奇怪的是,生成新版本的工作没有问题。我正在执行以下命令:

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

新的空版本文件出现在我提供的文件夹中,没问题。但是当我想使用它迁移到它时

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

我得到了错误:

In NoMigrationsToExecute.php line 13:

  Could not find any migrations to execute. 

类似,如果我尝试执行:

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

错误:

In UnknownMigrationVersion.php line 14:

  Could not find migration version 20191003105717  

我正在使用php7.3,MariaDb,并且代码在一个无用的盒子中。

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',
            ],
        ],
    ],
];

我根据这两个教程章节进行了配置:
Database Management with Doctrine ORM
Database Migrations

感谢您的帮助!

编辑: 以下是完整详细信息的输出:

./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>]

这似乎不是迁移问题,但是错误在哪里呢?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,我解决了使用正确的修改 migration_namespace 的问题,您可以在生成的版本类中找到该问题。