From 727647902cb50d708f4f2e046f3136b80aeed8e8 Mon Sep 17 00:00:00 2001 From: nemekzg Date: Sat, 17 Nov 2012 16:17:09 +0100 Subject: [PATCH] Fix for DDC-1765 --- .../Command/SchemaTool/UpdateCommand.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php index 97f620dbc..dc3d065ca 100644 --- a/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php +++ b/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/UpdateCommand.php @@ -82,6 +82,10 @@ Alternatively, you can execute the generated queries: %command.name% --force +If both options are specified, the queries are output and then executed: + +%command.name% --dump-sql --force + Finally, be aware that if the --complete option is passed, this task will drop all database assets (e.g. tables, etc) that are *not* described by the current metadata. In other words, without this option, this task leaves @@ -107,31 +111,30 @@ EOT $dumpSql = true === $input->getOption('dump-sql'); $force = true === $input->getOption('force'); - if ($dumpSql && $force) { - throw new \InvalidArgumentException('You can pass either the --dump-sql or the --force option (but not both simultaneously).'); - } - if ($dumpSql) { $output->writeln(implode(';' . PHP_EOL, $sqls)); - - return 0; } if ($force) { + if ($dumpSql) { + $output->writeln(''); + } $output->writeln('Updating database schema...'); $schemaTool->updateSchema($metadatas, $saveMode); $output->writeln(sprintf('Database schema updated successfully! "%s" queries were executed', count($sqls))); - - return 0; } + if ($dumpSql || $force) { + return 0; + } + $output->writeln('ATTENTION: This operation should not be executed in a production environment.'); $output->writeln(' Use the incremental update to detect changes during development and use'); $output->writeln(' the SQL DDL provided to manually update your database in production.'); $output->writeln(''); $output->writeln(sprintf('The Schema-Tool would execute "%s" queries to update the database.', count($sqls))); - $output->writeln('Please run the operation by passing one of the following options:'); + $output->writeln('Please run the operation by passing one - or both - of the following options:'); $output->writeln(sprintf(' %s --force to execute the command', $this->getName())); $output->writeln(sprintf(' %s --dump-sql to dump the SQL statements to the screen', $this->getName()));