[英]Upgrading Symfony from 3 to 4 getting error: “no registered migrations”
Trying to upgrade a project from Symfony 3.x to 4.4 and running into some issues with the doctrine migrations.尝试将项目从 Symfony 3.x 升级到 4.4 并遇到 doctrine 迁移的一些问题。
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:运行以下命令打印出我的 doctrine 配置时:
php app/console config:dump-reference doctrine_migrations
It basically gives me the default doctrine migrations config information.它基本上给了我默认的 doctrine 迁移配置信息。
Currently the project does not use Symfony Flex as I'm suspecting that makes a difference on where this config lives within the project.目前该项目不使用Symfony Flex ,因为我怀疑这会对项目中此配置的位置产生影响。 Doctrine config I have inside my config/config.yml
file. Doctrine 配置在我的config/config.yml
文件中。
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运行 doctrine 迁移命令返回
+------------+----------------------+------------------------------------------------------------------------+
| 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我相信我在这里遗漏了一些东西来运行迁移,但似乎无法弄清楚
There is no config/config.yml
file in symfony4 by default. symfony4 默认没有config/config.yml
文件。 It seems that this file is ignored.似乎这个文件被忽略了。
Move your doctrine_migrations:
section from config/config.yml
to config/packages/doctrine_migrations.yaml
file将您的doctrine_migrations:
部分从config/config.yml
到config/packages/doctrine_migrations.yaml
文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.