我正在尝试用表填充数据库,但在生成它后我无法迁移到它。
我正在使用 Zend Framework 3 并使用 composer.phar 文件添加了学说-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,并且代码在一个 vagrant box 中。
配置\自动加载\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>]
这似乎不是迁移问题,但错误可能出在哪里?