mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 03:53:13 +00:00
Add option to dump SQL queries in stderr
This commit is contained in:
@@ -25,7 +25,8 @@ class module_console_systemUpgrade extends Command
|
|||||||
->setDescription('Upgrades Phraseanet to the latest version')
|
->setDescription('Upgrades Phraseanet to the latest version')
|
||||||
->addOption('yes', 'y', InputOption::VALUE_NONE, 'Answers yes to all questions and do not ask the user')
|
->addOption('yes', 'y', InputOption::VALUE_NONE, 'Answers yes to all questions and do not ask the user')
|
||||||
->addOption('force', 'f', InputOption::VALUE_NONE, 'Forces the upgrade even if there is a concurrent upgrade')
|
->addOption('force', 'f', InputOption::VALUE_NONE, 'Forces the upgrade even if there is a concurrent upgrade')
|
||||||
->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dumps SQL queries that can be used to clean database.');
|
->addOption('dump', 'd', InputOption::VALUE_NONE, 'Dumps SQL queries that can be used to clean database.')
|
||||||
|
->addOption('stderr', 's', InputOption::VALUE_NONE, 'Dumps SQL queries to stderr');
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -67,12 +68,24 @@ class module_console_systemUpgrade extends Command
|
|||||||
|
|
||||||
$queries = $this->getService('phraseanet.appbox')->forceUpgrade($upgrader, $this->container);
|
$queries = $this->getService('phraseanet.appbox')->forceUpgrade($upgrader, $this->container);
|
||||||
|
|
||||||
if ($input->getOption('dump')) {
|
if ($input->getOption('dump') || $input->getOption('stderr')) {
|
||||||
if (0 < count($queries)) {
|
if (0 < count($queries)) {
|
||||||
$output->writeln("Some SQL queries can be executed to optimize\n");
|
$output->writeln("Some SQL queries can be executed to optimize\n");
|
||||||
|
|
||||||
|
$stderr = $input->getOption('stderr');
|
||||||
|
|
||||||
|
if ($stderr) {
|
||||||
|
$handle = fopen('php://stderr', 'a');
|
||||||
|
}
|
||||||
foreach ($queries as $query) {
|
foreach ($queries as $query) {
|
||||||
$output->writeln(" ".$query['sql']);
|
if ($stderr) {
|
||||||
|
fwrite($handle, $query['sql']."\n");
|
||||||
|
} else {
|
||||||
|
$output->writeln(" ".$query['sql']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($stderr) {
|
||||||
|
fclose ($handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->writeln("\n");
|
$output->writeln("\n");
|
||||||
|
Reference in New Issue
Block a user