aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorZoddo <zoddo.ino@gmail.com>2015-09-13 17:15:35 +0200
committerZoddo <zoddo.ino@gmail.com>2015-09-20 12:29:33 +0200
commit60099cf97c13106b741ab779883a89a0dbc4b6fa (patch)
treef90ede2335fb9a79213d747687862fb1c0092f17 /phpBB/phpbb
parent2596fba487a067cba36b5ebe50e1c73e4dc954d3 (diff)
downloadforums-60099cf97c13106b741ab779883a89a0dbc4b6fa.tar
forums-60099cf97c13106b741ab779883a89a0dbc4b6fa.tar.gz
forums-60099cf97c13106b741ab779883a89a0dbc4b6fa.tar.bz2
forums-60099cf97c13106b741ab779883a89a0dbc4b6fa.tar.xz
forums-60099cf97c13106b741ab779883a89a0dbc4b6fa.zip
[ticket/14162] Add CLI command db:list
This command lists all installed and uninstalled migrations. Note: The class is named `list_command`, because `list` is a reserved word and can't be used as class name in PHP. PHPBB3-14162
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/console/command/db/list_command.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/phpBB/phpbb/console/command/db/list_command.php b/phpBB/phpbb/console/command/db/list_command.php
new file mode 100644
index 0000000000..708107b592
--- /dev/null
+++ b/phpBB/phpbb/console/command/db/list_command.php
@@ -0,0 +1,73 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+namespace phpbb\console\command\db;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class list_command extends \phpbb\console\command\db\migration_command
+{
+ protected function configure()
+ {
+ $this
+ ->setName('db:list')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_DB_LIST'))
+ ->addOption(
+ 'available',
+ 'u',
+ InputOption::VALUE_NONE,
+ $this->user->lang('CLI_MIGRATIONS_ONLY_AVAILABLE')
+ )
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $show_installed = !$input->getOption('available');
+ $installed = $available = array();
+
+ foreach ($this->load_migrations() as $name)
+ {
+ if ($this->migrator->migration_state($name) !== false)
+ {
+ $installed[] = $name;
+ }
+ else
+ {
+ $available[] = $name;
+ }
+ }
+
+ if ($show_installed)
+ {
+ $output->writeln('<info>' . $this->user->lang('CLI_MIGRATIONS_INSTALLED') . $this->user->lang('COLON') . '</info>');
+ $output->writeln($installed);
+
+ if (empty($installed))
+ {
+ $output->writeln($this->user->lang('CLI_MIGRATIONS_EMPTY'));
+ }
+
+ $output->writeln('');
+ }
+
+ $output->writeln('<info>' . $this->user->lang('CLI_MIGRATIONS_AVAILABLE') . $this->user->lang('COLON') . '</info>');
+ $output->writeln($available);
+
+ if (empty($available))
+ {
+ $output->writeln($this->user->lang('CLI_MIGRATIONS_EMPTY'));
+ }
+ }
+}