1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

[ticket/13126] Improve the feedback when running the migrations

PHPBB3-13126
This commit is contained in:
Tristan Darricau
2014-10-14 17:58:29 +02:00
parent 29b54d12cc
commit 56d7c2c6ed
5 changed files with 147 additions and 56 deletions

View File

@@ -53,6 +53,30 @@ class migrate extends \phpbb\console\command\command
protected function execute(InputInterface $input, OutputInterface $output)
{
$user = $this->user;
$this->migrator->set_output_handler(
new \phpbb\db\migrator_output_handler(
function($message, $verbosity) use ($output, $user)
{
if ($verbosity <= $output->getVerbosity())
{
$final_message = call_user_func_array(array($user, 'lang'), $message);
if ($verbosity === \phpbb\db\migrator_output_handler::VERBOSITY_NORMAL)
{
$final_message = '<info>' . $final_message . '</info>';
}
else if ($verbosity === \phpbb\db\migrator_output_handler::VERBOSITY_VERY_VERBOSE)
{
$final_message = '<comment>' . $final_message . '</comment>';
}
$output->writeln($final_message);
}
}
)
);
$this->migrator->create_migrations_table();
$this->cache->purge();
@@ -61,8 +85,6 @@ class migrate extends \phpbb\console\command\command
$orig_version = $this->config['version'];
while (!$this->migrator->finished())
{
$migration_start_time = microtime(true);
try
{
$this->migrator->update();
@@ -73,36 +95,6 @@ class migrate extends \phpbb\console\command\command
$this->finalise_update();
return 1;
}
$migration_stop_time = microtime(true) - $migration_start_time;
$state = array_merge(
array(
'migration_schema_done' => false,
'migration_data_done' => false,
),
$this->migrator->last_run_migration['state']
);
if (!empty($this->migrator->last_run_migration['effectively_installed']))
{
$msg = $this->user->lang('MIGRATION_EFFECTIVELY_INSTALLED', $this->migrator->last_run_migration['name']);
$output->writeln("<comment>$msg</comment>");
}
else if ($this->migrator->last_run_migration['task'] == 'process_data_step' && $state['migration_data_done'])
{
$msg = $this->user->lang('MIGRATION_DATA_DONE', $this->migrator->last_run_migration['name'], $migration_stop_time);
$output->writeln("<info>$msg</info>");
}
else if ($this->migrator->last_run_migration['task'] == 'process_data_step')
{
$output->writeln($this->user->lang('MIGRATION_DATA_IN_PROGRESS', $this->migrator->last_run_migration['name'], $migration_stop_time));
}
else if ($state['migration_schema_done'])
{
$msg = $this->user->lang('MIGRATION_SCHEMA_DONE', $this->migrator->last_run_migration['name'], $migration_stop_time);
$output->writeln("<info>$msg</info>");
}
}
if ($orig_version != $this->config['version'])