简体   繁体   中英

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

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);

I just stumbled over your post, as I was having the same problem. Doctrine Migrations seem to been updated meanwhile (I guess: https://github.com/doctrine/migrations/commit/5b2751f149bc38d38870578f753c2193eb36e742 ).

Hence

 php app/console --no-interaction doctrine:migrations:migrate

now works fine.

I don't like Tom his approach and there is a other way to get this done:

<?php
$input = new Symfony\Components\Console\Input\ArrayInput(
    array(
        'migrations:migrate',
        '--configuration' => APPLICATION_PATH . '/../doctrine/migrations.xml',
    )
);
$input->setInteractive(false);
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM