1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-17 22:28:46 +01:00

[ticket/12870] Create the migrations table in db:migrate

PHPBB3-12870
This commit is contained in:
Tristan Darricau 2014-07-26 11:50:28 +02:00
parent 9d6ff36c6c
commit 8b8e09f4d5
3 changed files with 31 additions and 6 deletions

View File

@ -84,6 +84,8 @@ services:
- @config
- @cache
- @log
- @dbal.tools
- %core.table_prefix%
tags:
- { name: console.command }

View File

@ -32,13 +32,21 @@ class migrate extends \phpbb\console\command\command
/** @var \phpbb\log\log */
protected $log;
function __construct(\phpbb\user $user, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log)
/** @var \phpbb\db\tools */
protected $db_tools;
/** @var string */
protected $table_prefix;
function __construct(\phpbb\user $user, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log, \phpbb\db\tools $db_tools, $table_prefix)
{
$this->migrator = $migrator;
$this->extension_manager = $extension_manager;
$this->config = $config;
$this->cache = $cache;
$this->log = $log;
$this->db_tools = $db_tools;
$this->table_prefix = $table_prefix;
parent::__construct($user);
$this->user->add_lang(array('common', 'install', 'migrator'));
}
@ -53,6 +61,23 @@ class migrate extends \phpbb\console\command\command
protected function execute(InputInterface $input, OutputInterface $output)
{
// 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',
));
}
$this->load_migrations();
$orig_version = $this->config['version'];
while (!$this->migrator->finished())

View File

@ -77,11 +77,9 @@ class manager
{
$this->extensions = array();
// Do not try to load any extensions 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'))
// Do not try to load any extensions if the extension table
// does not exist. (The table is crated by the firsts migrations).
if (version_compare($this->config['version'], '3.1.0-dev', '<'))
{
return;
}