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