这是我被困的地方:
我正在使用最新版本调用执行教义迁移的api。
它运行一个命令。
当我手动执行命令时,这里是输出(THE JOB IS DONE): ==配置
>> Name: Application Migrations
>> Database Driver: pdo_sqlsrv
>> Database Name: xxxxxxxxxx
>> Configuration Source: manually configured
>> Version Table Name: Dsys_migration_versions
>> Version Column Name: version
>> Migrations Namespace: Application\Migrations
>> Migrations Directory: /var/www/xxxx/app/DoctrineMigrations
>> Previous Version: (20170503101946CreateSettingTable)
>> Current Version: (20170621150818CreateCalculatedfieldQuery)
>> Next Version: Already at latest version
>> Latest Version: (20170621150818CreateCalculatedfieldQuery)
>> Executed Migrations: 19
>> Executed Unavailable Migrations: 0
>> Available Migrations: 19
>> New Migrations: 0
==可用的迁移版本
>> (20170307111115CreateCustomTableTable) migrated
>> (20170307111322CreateCustomFieldTable) migrated
>> (20170307111324CreatePresetFieldTable) migrated
>> (20170307111326CreateDimensionTable) migrated
>> (20170307111328CreateCustomFieldChoiceTable) migrated
>> (20170307111329CreateImportScheduleTable) migrated
>> (20170307111331CreateMappedFieldTable) migrated
>> (20170307111332CreateImportTaskTable) migrated
>> (20170307111334CreateSegmentationQueryTable) migrated
>> (20170307111335CreateSegmentationQueryJoinTable) migrated
>> (20170307111336CreateCalculatedFieldSettingTable) migrated
>> (20170307111338CreateBlacklistTable) migrated
>> (20170307151829CreateCalculatedFieldFilterTable) migrated
>> (20170315105949CreateImportTable) migrated
>> (20170403134126CreateFamilyTable) migrated
>> (20170410124309CreateUserTable) migrated
>> (20170412103331CreateCalculatedFieldJoinTable) migrated
>> (20170503101946CreateSettingTable) migrated
>> (20170621150818CreateCalculatedfieldQuery) migrated
当我调用运行命令的api时(似乎遵循完全相同的路径)(JOB NOT DONE):
==配置
>> Name: Application Migrations
>> Database Driver: pdo_sqlsrv
>> Database Name: xxxxxxxxxxxx
>> Configuration Source: manually configured
>> Version Table Name: Dsys_migration_versions
>> Version Column Name: version
>> Migrations Namespace: Application\Migrations
>> Migrations Directory: /var/www/xxxxxx/app/DoctrineMigrations
>> Previous Version: Already at first version
>> Current Version: 0
>> Next Version: (20170307111115CreateCustomTableTable)
>> Latest Version: (20170621150818CreateCalculatedfieldQuery)
>> Executed Migrations: 0
>> Executed Unavailable Migrations: 0
>> Available Migrations: 19
>> New Migrations: 19
==可用的迁移版本
>> (20170307111115CreateCustomTableTable) not migrated
>> (20170307111322CreateCustomFieldTable) not migrated
>> (20170307111324CreatePresetFieldTable) not migrated
>> (20170307111326CreateDimensionTable) not migrated
>> (20170307111328CreateCustomFieldChoiceTable) not migrated
>> (20170307111329CreateImportScheduleTable) not migrated
>> (20170307111331CreateMappedFieldTable) not migrated
>> (20170307111332CreateImportTaskTable) not migrated
>> (20170307111334CreateSegmentationQueryTable) not migrated
>> (20170307111335CreateSegmentationQueryJoinTable) not migrated
>> (20170307111336CreateCalculatedFieldSettingTable) not migrated
>> (20170307111338CreateBlacklistTable) not migrated
>> (20170307151829CreateCalculatedFieldFilterTable) not migrated
>> (20170315105949CreateImportTable) not migrated
>> (20170403134126CreateFamilyTable) not migrated
>> (20170410124309CreateUserTable) not migrated
>> (20170412103331CreateCalculatedFieldJoinTable) not migrated
>> (20170503101946CreateSettingTable) not migrated
>> (20170621150818CreateCalculatedfieldQuery) not migrated
我可以通过bin / console doctrine:migrations:migrate命令执行等待迁移。我不知道为什么没有这个就没有工作。
以下是调用doctrine的最后一个函数:migration:migrate:
private function migrateDatabase(OutputInterface $output, string $version = 'latest')
{
$command = $this->getApplication()->find('doctrine:migrations:migrate');
$arguments = ['version' => $version];
$inputCommand = new ArrayInput($arguments);
$inputCommand->setInteractive(false);
if ($command->run($inputCommand, $output) !== 0) {
$output->writeln('<error>Fail : errors in database migrations.</error>');
}
}
如果我在调用api时转储$ output,则会提示:没有可迁移的迁移。当显然在constole一个学说:迁移:状态输出19等待等待......
另外,你必须知道,这个该死的东西,当一个目标某个数据库时起作用,但是当我定位其他数据库时失败。我绝对无法区分,因为它们是副本和彼此的过去...这就是为什么我需要调试,我可以忽略它,只是把它看作一个随机的bug但是当这个东西上线时,我不想要一个不好的惊喜
[编辑] 它的getMigrationsToExecute($ direction,$ to)在我调试的情况下返回空,开始查找原因。如果你有任何线索。
任何帮助将不胜感激,
感谢阅读。
答案 0 :(得分:0)
我终于找到了什么问题,但还没找到任何解决方案。
在挖掘symfony和教义的四肢时,我停止了这个功能:
public function getMigratedVersions()
{
$this->connect();
$this->createMigrationTable();
$ret = $this->connection->fetchAll("SELECT " . $this->migrationsColumnName . " FROM " . $this->migrationsTableName);
return array_map('current', $ret);
}
并返回一些东西,当它不应该。
为什么?因为它在错误的数据库上执行.....为什么?我不知道, 我抛弃了$ this-&gt; connection-&gt; getDatabase();并将其设置为正确的,但在另一个上执行查询。
这就是现在的问题,为什么它没有选择正确的数据库,即使它被正确输入了?
干杯。