Skip to content

Commit

Permalink
fix(migration): change way to create dependencyFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
mikel00per committed Mar 21, 2024
1 parent 785a87f commit b458b63
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bin/cli
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand;
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
use Doctrine\Migrations\Configuration\Configuration;
use Doctrine\Migrations\Configuration\Connection\ExistingConnection;
use Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager;
use Doctrine\Migrations\Configuration\Migration\ExistingConfiguration;
use Doctrine\Migrations\DependencyFactory;
use Doctrine\Migrations\Exception\MigrationException;
Expand Down Expand Up @@ -75,7 +76,7 @@ try {

$cli->addCommands([
// Migrations commands
...getMigrationCommands($settings),
...getMigrationCommands($container),
// DBAL Commands
...getDbalCommands($container),
// ORM Commands
Expand All @@ -95,13 +96,12 @@ try {
]);
}


/**
* @throws MigrationException|\Doctrine\DBAL\Exception
* @throws NotFoundExceptionInterface|ContainerExceptionInterface|MigrationException
*/
function getMigrationCommands(SettingsInterface $settings): array
function getMigrationCommands(ContainerInterface $container): array
{
$connection = DriverManager::getConnection($settings->get('orm.database'));
$settings = $container->get(SettingsInterface::class);

$configuration = new Configuration();

Expand All @@ -119,9 +119,10 @@ function getMigrationCommands(SettingsInterface $settings): array
$configuration->setMetadataStorageConfiguration($storageConfiguration);
$configuration->setMigrationsAreOrganizedByYearAndMonth();

$dependencyFactory = DependencyFactory::fromConnection(
$dependencyFactory = DependencyFactory::fromEntityManager(
new ExistingConfiguration($configuration),
new ExistingConnection($connection)
new ExistingEntityManager($container->get(EntityManager::class)),
$container->get(LoggerInterface::class)
);

return [
Expand Down

0 comments on commit b458b63

Please sign in to comment.