diff --git a/src/Maker/MakeMigration.php b/src/Maker/MakeMigration.php index 602de9d3ec..3f0910c217 100644 --- a/src/Maker/MakeMigration.php +++ b/src/Maker/MakeMigration.php @@ -70,6 +70,9 @@ public function configureCommand(Command $command, InputConfiguration $inputConf ->addOption('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection name') ; } + + $command + ->addOption('formatted', null, InputOption::VALUE_NONE, 'Format the generated SQL'); } public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator) @@ -88,6 +91,10 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen } // end 2.x support + if ($input->hasOption('formatted') && null !== $input->getOption('formatted')) { + $options[] = '--formatted'; + } + $generateMigrationCommand = $this->application->find('doctrine:migrations:diff'); $generateMigrationCommandInput = new ArgvInput($options); diff --git a/tests/Maker/MakeMigrationTest.php b/tests/Maker/MakeMigrationTest.php index 4e5711151d..f5ddeb614d 100644 --- a/tests/Maker/MakeMigrationTest.php +++ b/tests/Maker/MakeMigrationTest.php @@ -131,5 +131,17 @@ public function getTestDetails(): \Generator $this->assertStringNotContainsString('Success', $output); }), ]; + + yield 'it_generate_a_formatted_migration' => [$this->createMakeMigrationTest() + ->addRequiredPackageVersion('doctrine/doctrine-migrations-bundle', '>=3') + ->run(function (MakerTestRunner $runner) { + + $runner->runConsole('make:migration', [], '--formatted'); + + $output = $runner->runMaker([/* no input */]); + + $this->assertStringContainsString('Success', $output); + }), + ]; } }