aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2014-07-28 18:13:44 +0200
committerAndreas Fischer <bantu@phpbb.com>2014-07-28 18:13:44 +0200
commite992eab4c3f39d22acacac70c95c62b942ca36ff (patch)
treecb4111d8c139694480856527ceb8aeffd5820994
parentd8867bb40de290a4c7377444dac0f5d07950e88a (diff)
parentae350bda4276d245a8480242a8c803a840922ece (diff)
downloadforums-e992eab4c3f39d22acacac70c95c62b942ca36ff.tar
forums-e992eab4c3f39d22acacac70c95c62b942ca36ff.tar.gz
forums-e992eab4c3f39d22acacac70c95c62b942ca36ff.tar.bz2
forums-e992eab4c3f39d22acacac70c95c62b942ca36ff.tar.xz
forums-e992eab4c3f39d22acacac70c95c62b942ca36ff.zip
Merge pull request #2780 from Nicofuma/ticket/12870
[ticket/12870] phpbbcli.php db:migrate can not update from 3.0.12 to 3.1 * Nicofuma/ticket/12870: [ticket/12870] Add doc block [ticket/12870] Create the migrations table with a method in the migrator [ticket/12870] Add $config['version'] in phpbb_extension_manager_test [ticket/12870] Create the migrations table in db:migrate
-rw-r--r--phpBB/install/database_update.php20
-rw-r--r--phpBB/phpbb/console/command/db/migrate.php2
-rw-r--r--phpBB/phpbb/db/migrator.php24
-rw-r--r--phpBB/phpbb/extension/manager.php5
-rw-r--r--tests/extension/manager_test.php2
5 files changed, 32 insertions, 21 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index c54c84cdbc..517143792a 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -177,25 +177,9 @@ define('IN_DB_UPDATE', true);
// End startup code
-// Make sure migrations have been installed.
-$db_tools = $phpbb_container->get('dbal.tools');
-if (!$db_tools->sql_table_exists($table_prefix . 'migrations'))
-{
- $db_tools->sql_create_table($table_prefix . 'migrations', array(
- 'COLUMNS' => array(
- 'migration_name' => array('VCHAR', ''),
- 'migration_depends_on' => array('TEXT', ''),
- 'migration_schema_done' => array('BOOL', 0),
- 'migration_data_done' => array('BOOL', 0),
- 'migration_data_state' => array('TEXT', ''),
- 'migration_start_time' => array('TIMESTAMP', 0),
- 'migration_end_time' => array('TIMESTAMP', 0),
- ),
- 'PRIMARY_KEY' => 'migration_name',
- ));
-}
-
$migrator = $phpbb_container->get('migrator');
+$migrator->create_migrations_table();
+
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
$finder = $phpbb_extension_manager->get_finder();
diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php
index bb5f83b16f..c3caae5f70 100644
--- a/phpBB/phpbb/console/command/db/migrate.php
+++ b/phpBB/phpbb/console/command/db/migrate.php
@@ -53,6 +53,8 @@ class migrate extends \phpbb\console\command\command
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $this->migrator->create_migrations_table();
+
$this->load_migrations();
$orig_version = $this->config['version'];
while (!$this->migrator->finished())
diff --git a/phpBB/phpbb/db/migrator.php b/phpBB/phpbb/db/migrator.php
index 8b089a060f..8bc63e564a 100644
--- a/phpBB/phpbb/db/migrator.php
+++ b/phpBB/phpbb/db/migrator.php
@@ -767,4 +767,28 @@ class migrator
return $this->migrations;
}
+
+ /**
+ * Creates the migrations table if it does not exist.
+ * @return null
+ */
+ public function create_migrations_table()
+ {
+ // Make sure migrations have been installed.
+ if (!$this->db_tools->sql_table_exists($this->table_prefix . 'migrations'))
+ {
+ $this->db_tools->sql_create_table($this->table_prefix . 'migrations', array(
+ 'COLUMNS' => array(
+ 'migration_name' => array('VCHAR', ''),
+ 'migration_depends_on' => array('TEXT', ''),
+ 'migration_schema_done' => array('BOOL', 0),
+ 'migration_data_done' => array('BOOL', 0),
+ 'migration_data_state' => array('TEXT', ''),
+ 'migration_start_time' => array('TIMESTAMP', 0),
+ 'migration_end_time' => array('TIMESTAMP', 0),
+ ),
+ 'PRIMARY_KEY' => 'migration_name',
+ ));
+ }
+ }
}
diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php
index b19eb9f8a3..4a12e9ec8c 100644
--- a/phpBB/phpbb/extension/manager.php
+++ b/phpBB/phpbb/extension/manager.php
@@ -77,11 +77,12 @@ class manager
{
$this->extensions = array();
- // Do not try to load any extensions when installing or updating
+ // Do not try to load any extensions if the extension table
+ // does not exist or when installing or updating.
// Note: database updater invokes this code, and in 3.0
// there is no extension table therefore the rest of this function
// fails
- if (defined('IN_INSTALL'))
+ if (defined('IN_INSTALL') || version_compare($this->config['version'], '3.1.0-dev', '<'))
{
return;
}
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index 230c90c7c7..067fd62581 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -135,7 +135,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
protected function create_extension_manager($with_cache = true)
{
- $config = new \phpbb\config\config(array());
+ $config = new \phpbb\config\config(array('version' => PHPBB_VERSION));
$db = $this->new_dbal();
$db_tools = new \phpbb\db\tools($db);
$phpbb_root_path = __DIR__ . './../../phpBB/';