From 8b8e09f4d52cfa2d9d951d827114b2ae510dbfc8 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 26 Jul 2014 11:50:28 +0200 Subject: [ticket/12870] Create the migrations table in db:migrate PHPBB3-12870 --- phpBB/phpbb/console/command/db/migrate.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/db') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 758b125b13..29f0fe7c16 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -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()) -- cgit v1.2.1 From a8e81b6e9f42c3187d7b17c6bb5da052c28944a6 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 27 Jul 2014 11:08:13 +0200 Subject: [ticket/12870] Create the migrations table with a method in the migrator PHPBB3-12870 --- phpBB/phpbb/console/command/db/migrate.php | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'phpBB/phpbb/console/command/db') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 29f0fe7c16..dc16ed0699 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -32,21 +32,13 @@ class migrate extends \phpbb\console\command\command /** @var \phpbb\log\log */ protected $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) + 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) { $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')); } @@ -61,22 +53,7 @@ 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->migrator->create_migrations_table(); $this->load_migrations(); $orig_version = $this->config['version']; -- cgit v1.2.1