doctrine-migrations cannt run with api when the database driver is sqlite

I’m trying to integrate doctrine/migrations into the TP5 framework for unit testing purposes, so I need to use the API provided by doctrine-migrations to run migrations instead of the CLI. However, I encountered this error when using the SQLite engine: The metadata storage is not initialized, please run the sync-metadata-storage command to fix this issue.

There is my code

$connectionLoader = new ConfigurationFile('./migrations-db.php');
$configurationLoader = new ConfigurationFileWithFallback('./migrations.php');
$dependencyFactory = DependencyFactory::fromConnection($configurationLoader, $connectionLoader);
$version = $dependencyFactory->getVersionAliasResolver()->resolveVersionAlias('latest');
$planCalculator = $dependencyFactory->getMigrationPlanCalculator();
$plan = $planCalculator->getPlanUntilVersion($version);
$migrator = $dependencyFactory->getMigrator();
$migratorConfigurationFactory = $dependencyFactory->getConsoleInputMigratorConfigurationFactory();
$migratorConfiguration = $migratorConfigurationFactory->getMigratorConfiguration(new ArrayInput([]));
$sql = $migrator->migrate($plan, $migratorConfiguration);

There is my migrations-db.php

<?php
// return [
//     'driver' => 'pdo_mysql',
//     'host' => '127.0.0.1',
//     'port' => 13306,
//     'password' => 'zhihui',
//     'dbname' => 'migration',
//     'user' => 'root',
// ];

return [
    'driver' => 'pdo_sqlite',
    'dbname' => ':memory:',
];

As you can see, everything works fine when the driver is ‘mysql_pdo’.

However, strangely enough, no matter which driver I choose, running doctrine-migrations:migrate in the CLI works without any issues.”