views:

99

answers:

1

How can I run a doctrine 2 migration command without interaction?

Currently I have following command which runs on the setup of my Unit Tests. But It always prompt for a Yes/No user input, even when I use the --no-interaction option.

$input = new Symfony\Components\Console\Input\ArrayInput(
        array(
            'migrations:migrate',
            '--configuration' => APPLICATION_PATH . '/../doctrine/migrations.xml',
            '--no-interaction',
            )
        );
$cli->run($input);
A: 

It seems that the --no-interaction isn't working. What I've done to solve my problem is:

  • Created a bash script in the doctrine migrations directory.
  • Execute the bash script in the bootstrap of my unit test suite.

The bash script which executes the doctrine migrations

    #!/bin/bash
    php doctrine migrations:migrate 0 << EOF
    Y
    EOF
    php doctrine migrations:migrate << EOF
    Y
    EOF

Code in my bootstrap:

chdir(APPLICATION_PATH .'/../doctrine');
exec('./unitTestsReload');
chdir(APPLICATION_PATH .'/../tests');

It's not the best solution I think, but it works for me.

Skelton