From 2596fba487a067cba36b5ebe50e1c73e4dc954d3 Mon Sep 17 00:00:00 2001 From: Zoddo Date: Sun, 13 Sep 2015 16:08:22 +0200 Subject: [ticket/14162] Add CLI command db:revert This command allow to revert a migration from the CLI PHPBB3-14162 --- phpBB/phpbb/db/migrator.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'phpBB/phpbb/db/migrator.php') diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php index 6902913c64..18c6403c07 100644 --- a/phpBB/phpbb/db/migrator.php +++ b/phpBB/phpbb/db/migrator.php @@ -416,6 +416,9 @@ class migrator if ($state['migration_data_done']) { + $this->output_handler->write(array('MIGRATION_REVERT_DATA_RUNNING', $name), migrator_output_handler_interface::VERBOSITY_VERBOSE); + $elapsed_time = microtime(true); + if ($state['migration_data_state'] !== 'revert_data') { $result = $this->process_data_step($migration->update_data(), $state['migration_data_state'], true); @@ -431,9 +434,22 @@ class migrator } $this->set_migration_state($name, $state); + + $elapsed_time = microtime(true) - $elapsed_time; + if ($state['migration_data_done']) + { + $this->output_handler->write(array('MIGRATION_REVERT_DATA_DONE', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_NORMAL); + } + else + { + $this->output_handler->write(array('MIGRATION_REVERT_DATA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE); + } } else if ($state['migration_schema_done']) { + $this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_RUNNING', $name), migrator_output_handler_interface::VERBOSITY_VERBOSE); + $elapsed_time = microtime(true); + $steps = $this->helper->get_schema_steps($migration->revert_schema()); $result = $this->process_data_step($steps, $state['migration_data_state']); @@ -448,6 +464,9 @@ class migrator unset($this->migration_state[$name]); } + + $elapsed_time = microtime(true) - $elapsed_time; + $this->output_handler->write(array('MIGRATION_REVERT_SCHEMA_DONE', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_NORMAL); } return true; -- cgit v1.2.1