我遇到了Phinx迁移的问题,目前我正在处理表关系,我必须使用Phinx创建外键,但当我运行命令phinx migrate
时,发生了错误。Error: Call to undefined method Phinx\Db\Adapter\MysqlAdapter::getCakeConnection() in \cms\vendor\cakephp\migrations\src\Table.php on line 79
个
我找不到任何线索。
这是详细信息错误:
call C:\path\development\cms\vendor\robmorgan\phinx\bin\phinx.bat migrate
Phinx by Rob Morgan - https://phinx.org. 0.8.1
using config file .\phinx.yml using config parser yaml using migration
paths
- C:\path\development\cms\config\db\migrations
using seed paths
- C:\path\development\cms\config\db\seeds warning no environment specified, defaulting to: development using
adapter mysql using database app_db
== 20180509032904 CreateDevices: migrating
Fatal error: Uncaught Error: Call to undefined method
Phinx\Db\Adapter\MysqlAdapter::getCakeConnection() in
C:\path\development\cms\vendor\cakephp\migrations\src\Table.php
on line 79
Error: Call to undefined method
Phinx\Db\Adapter\MysqlAdapter::getCakeConnection() in
C:\path\development\cms\vendor\cakephp\migrations\src\Table.php
on line 79
Call Stack:
0.4312 413768 1. {main}() C:\path\development\cms\vendor\robmorgan\phinx\bin\phinx:0
0.4468 2004152 2. Phinx\Console\PhinxApplication->run() C:\path\development\cms\vendor\robmorgan\phinx\bin\phinx:28
0.5716 2236128 3. Phinx\Console\PhinxApplication->doRun() C:\path\development\cms\vendor\symfony\console\Application.php:148
0.5716 2236176 4. Phinx\Console\PhinxApplication->doRun() C:\path\development\cms\vendor\robmorgan\phinx\src\Phinx\Console\PhinxApplication.php:83
0.5716 2236176 5. Phinx\Console\PhinxApplication->doRunCommand()
C:\path\development\cms\vendor\symfony\console\Application.php:248
0.5716 2236176 6. Phinx\Console\Command\Migrate->run() C:\path\development\cms\vendor\symfony\console\Application.php:946
0.5716 2240328 7. Phinx\Console\Command\Migrate->execute() C:\path\development\cms\vendor\symfony\console\Command\Command.php:252
0.6028 2829928 8. Phinx\Migration\Manager->migrate() C:\path\development\cms\vendor\robmorgan\phinx\src\Phinx\Console\Command\Migrate.php:113
1.6454 3406784 9. Phinx\Migration\Manager->executeMigration() C:\path\development\cms\vendor\robmorgan\phinx\src\Phinx\Migration\Manager.php:342
1.6454 3406784 10. Phinx\Migration\Manager\Environment-executeMigration()
C:\path\development\cms\vendor\robmorgan\phinx\src\Phinx\Migration\Manager.php:366
1.6454 3406784 11. CreateDevices->change() C:\path\development\cms\vendor\robmorgan\phinx\src\Phinx\Migration\Manager\Environment.php:122
1.6454 3470712 12. Migrations\Table->create() C:\path\development\cms\config\db\migrations\20180509032904_create_devices.php:55
2条答案
按热度按时间ki0zmccv1#
我找到了原因,在我把CakePHP的默认迁移文件移到Phinx之前,我忘记了把使用命名空间改为使用Phinx\Migration\AbstractMigration;。现在Phinx可以正常运行了。感谢@Nico Haase
ih99xse12#
添加MysqlAdapter的使用。