From 16929b0a5d1efd473c2cc58b9bfae63c28d6757a Mon Sep 17 00:00:00 2001 From: Igor Mukhin Date: Wed, 29 Apr 2015 23:21:31 +0300 Subject: [PATCH] Fix issue #7 --- .../Command/InitializeApplicationCommand.php | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Acme/Task/Ui/CliBundle/Command/InitializeApplicationCommand.php b/src/Acme/Task/Ui/CliBundle/Command/InitializeApplicationCommand.php index 04ddf49..33092d9 100644 --- a/src/Acme/Task/Ui/CliBundle/Command/InitializeApplicationCommand.php +++ b/src/Acme/Task/Ui/CliBundle/Command/InitializeApplicationCommand.php @@ -42,14 +42,20 @@ protected function execute(InputInterface $input, OutputInterface $output) return -1; } - $commands = array( - 'doctrine:database:create' => array('--verbose' => true), - 'doctrine:schema:create' => array('--em' => 'write'), - 'acme:task:create-task-view-model-schema' => array(), - 'doctrine:fixtures:load' => array(), - ); + $commands = array(); + $commands[] = array('doctrine:database:create' , array('--verbose' => true, '--connection' => 'write')); + $commands[] = array('doctrine:schema:create' , array('--em' => 'write')); + + if ($this->getContainer()->getParameter('db_read_name') != $this->getContainer()->getParameter('db_write_name')) { + $commands[] = array('doctrine:database:create' , array('--verbose' => true, '--connection' => 'read')); + } + + $commands[] = array('acme:task:create-task-view-model-schema', array()); + $commands[] = array('doctrine:fixtures:load' , array()); + + foreach ($commands as $command) { + list($commandName, $commandOptions) = $command; - foreach ($commands as $commandName => $commandOptions) { $command = $this->getApplication()->find($commandName); $commandInput = new ArrayInput( array_merge(