Fix dbconvert
This commit is contained in:
parent
b57a1063a3
commit
4b8de8ba8e
|
@ -32,10 +32,14 @@ use \OCP\IConfig;
|
||||||
use OC\DB\Connection;
|
use OC\DB\Connection;
|
||||||
use OC\DB\ConnectionFactory;
|
use OC\DB\ConnectionFactory;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Helper\ProgressBar;
|
||||||
|
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||||
|
use Symfony\Component\Console\Question\Question;
|
||||||
|
|
||||||
class ConvertType extends Command {
|
class ConvertType extends Command {
|
||||||
/**
|
/**
|
||||||
|
@ -158,13 +162,12 @@ class ConvertType extends Command {
|
||||||
|
|
||||||
// Read password by interacting
|
// Read password by interacting
|
||||||
if ($input->isInteractive()) {
|
if ($input->isInteractive()) {
|
||||||
/** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
|
/** @var QuestionHelper $helper */
|
||||||
$dialog = $this->getHelperSet()->get('dialog');
|
$helper = $this->getHelper('question');
|
||||||
$password = $dialog->askHiddenResponse(
|
$question = new Question('What is the database password?');
|
||||||
$output,
|
$question->setHidden(true);
|
||||||
'<question>What is the database password?</question>',
|
$question->setHiddenFallback(false);
|
||||||
false
|
$password = $helper->ask($input, $output, $question);
|
||||||
);
|
|
||||||
$input->setOption('password', $password);
|
$input->setOption('password', $password);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -195,13 +198,12 @@ class ConvertType extends Command {
|
||||||
$output->writeln('<comment>Please note that tables belonging to available but currently not installed apps</comment>');
|
$output->writeln('<comment>Please note that tables belonging to available but currently not installed apps</comment>');
|
||||||
$output->writeln('<comment>can be included by specifying the --all-apps option.</comment>');
|
$output->writeln('<comment>can be included by specifying the --all-apps option.</comment>');
|
||||||
}
|
}
|
||||||
/** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
|
|
||||||
$dialog = $this->getHelperSet()->get('dialog');
|
/** @var QuestionHelper $helper */
|
||||||
if (!$dialog->askConfirmation(
|
$helper = $this->getHelper('question');
|
||||||
$output,
|
$question = new ConfirmationQuestion('Continue with the conversion (y/n)? [n] ', false);
|
||||||
'<question>Continue with the conversion (y/n)? [n] </question>',
|
|
||||||
false
|
if (!$helper->ask($input, $output, $question)) {
|
||||||
)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,9 +258,6 @@ class ConvertType extends Command {
|
||||||
protected function copyTable(Connection $fromDB, Connection $toDB, $table, InputInterface $input, OutputInterface $output) {
|
protected function copyTable(Connection $fromDB, Connection $toDB, $table, InputInterface $input, OutputInterface $output) {
|
||||||
$chunkSize = $input->getOption('chunk-size');
|
$chunkSize = $input->getOption('chunk-size');
|
||||||
|
|
||||||
/** @var $progress \Symfony\Component\Console\Helper\ProgressHelper */
|
|
||||||
$progress = $this->getHelperSet()->get('progress');
|
|
||||||
|
|
||||||
$query = $fromDB->getQueryBuilder();
|
$query = $fromDB->getQueryBuilder();
|
||||||
$query->automaticTablePrefix(false);
|
$query->automaticTablePrefix(false);
|
||||||
$query->selectAlias($query->createFunction('COUNT(*)'), 'num_entries')
|
$query->selectAlias($query->createFunction('COUNT(*)'), 'num_entries')
|
||||||
|
@ -272,11 +271,11 @@ class ConvertType extends Command {
|
||||||
$output->writeln('chunked query, ' . $numChunks . ' chunks');
|
$output->writeln('chunked query, ' . $numChunks . ' chunks');
|
||||||
}
|
}
|
||||||
|
|
||||||
$progress->start($output, $count);
|
$progress = new ProgressBar($output, $count);
|
||||||
|
$progress->start();
|
||||||
$redraw = $count > $chunkSize ? 100 : ($count > 100 ? 5 : 1);
|
$redraw = $count > $chunkSize ? 100 : ($count > 100 ? 5 : 1);
|
||||||
$progress->setRedrawFrequency($redraw);
|
$progress->setRedrawFrequency($redraw);
|
||||||
|
|
||||||
|
|
||||||
$query = $fromDB->getQueryBuilder();
|
$query = $fromDB->getQueryBuilder();
|
||||||
$query->automaticTablePrefix(false);
|
$query->automaticTablePrefix(false);
|
||||||
$query->select('*')
|
$query->select('*')
|
||||||
|
|
Loading…
Reference in New Issue