I have a setup with two different database connections, which also means two different entity managers. I'm trying to create a Symfony CLI command that calls the doctrine:migrations:migrate command with the --em, --configuration and --no-interaction options.
However, I struggle with the fact that despite having --no-interaction and $input->setInteractive(false), I still get prompted with a confirmation.
Take a look at the code:
protected function execute(InputInterface $input, OutputInterface $output) {
$input->setInteractive(false);
// some other code here
$command = $this->getApplication()->find('doctrine:migrations:migrate');
$arguments = array(
'command' => 'doctrine:migrations:migrate',
'version' => $version,
'--em' => $em,
'--configuration' => self::CONFIG_FILES[$em],
'--no-interaction' => true
);
$migrationInput = new ArrayInput($arguments);
$command->run($migrationInput, $output);
}
I tried pretty much everything that came to my mind. I couldn't see anywhere written that --no-interaction would not work with commands called from another command. Everytime I run that command I simply get the following:
WARNING! You are about to execute a database migration that could result in schema changes
and data lost. Are you sure you wish to continue? (y/n)
Which then prompts me to answer. Any idea?