Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony&;学说迁移_Symfony_Doctrine - Fatal编程技术网

Symfony&;学说迁移

Symfony&;学说迁移,symfony,doctrine,Symfony,Doctrine,这就是我被困的地方: 我正在调用一个api,该api使用最新版本执行条令迁移 它运行一个命令 当我手动执行命令时,这里是输出(作业完成): ==配置 >> Name: Application Migrations >> Database Driver: pdo_sqlsrv >> Database N

这就是我被困的地方:

我正在调用一个api,该api使用最新版本执行条令迁移

它运行一个命令

当我手动执行命令时,这里是输出(作业完成): ==配置

>> 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
>> 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)             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
>>  (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
当我调用运行命令的api时(似乎遵循完全相同的路径)(作业未完成):

==配置

>> 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
>> 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)             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
>>  (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原则:migrations:migrate命令执行等待迁移。我不知道为什么没有这个工作就不能完成

下面是最后一个函数调用原则:migrations: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>');
    }
}
private function migrateDatabase(OutputInterface$output,string$version='latest')
{
$command=$this->getApplication()->find('doctrine:migrations:migrate');
$arguments=['version'=>$version];
$inputCommand=newarrayinput($arguments);
$inputCommand->setInteractive(false);
如果($command->run($inputCommand,$output)!==0){
$output->writeln('Fail:数据库迁移中出现错误');
}
}
如果我在调用api时转储$output,它会提示:无迁移可用。很明显,在康斯托尔有一条原则:迁移:状态输出19迁移等待

另外,你必须知道,这个该死的东西,当一个目标指向某个数据库时有效,但当我指向其他数据库时失败。我绝对分不清它们之间的区别,因为它们是彼此的复制品和过去。。。这就是为什么我需要调试,我可以忽略它,只是把它看作是一个随机的错误,但当这个东西上线时,我不想看到一个坏的惊喜

[编辑] 它是getMigrationsToExecute($direction,$to),在我调试的情况下返回空值,并开始查找原因。如果你有任何线索

任何帮助都将不胜感激


谢谢阅读。

我终于找到了问题所在,但还没有找到任何解决方案

在挖掘symfony和doctrine的肢体时,我停止了这个功能:

public function getMigratedVersions()
{
    $this->connect();
    $this->createMigrationTable();

    $ret = $this->connection->fetchAll("SELECT " . $this->migrationsColumnName . " FROM " . $this->migrationsTableName);

    return array_map('current', $ret);
}
当它不应该返回时,它会返回一些东西

为什么??因为它在错误的数据库上执行。。。。。为什么?我不知道, 我转储了$this->connection->getDatabase();并将其设置为正确的,但对另一个执行查询

这就是现在的重点,为什么即使正确地输入了数据库,它也不选择正确的数据库


干杯。

我终于找到了问题所在,但还没有找到任何解决办法

在挖掘symfony和doctrine的肢体时,我停止了这个功能:

public function getMigratedVersions()
{
    $this->connect();
    $this->createMigrationTable();

    $ret = $this->connection->fetchAll("SELECT " . $this->migrationsColumnName . " FROM " . $this->migrationsTableName);

    return array_map('current', $ret);
}
当它不应该返回时,它会返回一些东西

为什么??因为它在错误的数据库上执行。。。。。为什么?我不知道, 我转储了$this->connection->getDatabase();并将其设置为正确的,但对另一个执行查询

这就是现在的重点,为什么即使正确地输入了数据库,它也不选择正确的数据库


干杯。

从api和控制台输出的
数据库名称是否相同?条令使用一个表(迁移版本)来存储已执行的迁移。是的,它是相同的。。。我也将setInteractive设置为false,所以这与提示无关,理论上也不是。另外,我已经在api调用中正确创建了store proc,因此它确认DB是正确的。您能告诉我们在您的api上执行最新原则迁移的代码部分吗?从api和控制台输出的
数据库名称是否相同?条令使用一个表(迁移版本)来存储已执行的迁移。是的,它是相同的。。。我也将setInteractive设置为false,所以这与提示无关,理论上也不是。另外,我已经在api调用中正确创建了store proc,因此它确认DB是正确的。您能告诉我们在您的api上执行最新原则迁移的代码部分吗?