Skip to content
Permalink
Browse files

Add support of additional database from settings for drop db command (#…

  • Loading branch information...
LOBsTerr committed Apr 10, 2019
1 parent b52f3e9 commit efe17e2388c963f24d62b48652f81bbf64320250
Showing with 12 additions and 19 deletions.
  1. +0 −1 config/services/database.yml
  2. +12 −18 src/Command/Database/DropCommand.php
@@ -18,7 +18,6 @@ services:
- { name: drupal.command }
console.database_drop:
class: Drupal\Console\Command\Database\DropCommand
arguments: ['@database']
tags:
- { name: drupal.command }
console.database_dump:
@@ -13,6 +13,7 @@
use Drupal\Console\Core\Command\Command;
use Drupal\Core\Database\Connection;
use Drupal\Console\Command\Shared\ConnectTrait;
use Drupal\Core\Database\Database;
/**
* Class DropCommand
@@ -23,22 +24,6 @@ class DropCommand extends Command
{
use ConnectTrait;
/**
* @var Connection
*/
protected $database;
/**
* DropCommand constructor.
*
* @param Connection $database
*/
public function __construct(Connection $database)
{
$this->database = $database;
parent::__construct();
}
/**
* {@inheritdoc}
*/
@@ -53,6 +38,12 @@ protected function configure()
$this->trans('commands.database.drop.arguments.database'),
'default'
)
->addArgument(
'target',
InputArgument::OPTIONAL,
$this->trans('commands.database.drop.arguments.target'),
'default'
)
->setHelp($this->trans('commands.database.drop.help'))
->setAliases(['dbd']);
}
@@ -63,9 +54,10 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$database = $input->getArgument('database');
$target = $input->getArgument('target');
$yes = $input->getOption('yes');
$databaseConnection = $this->resolveConnection($database);
$databaseConnection = $this->resolveConnection($database, $target);
if (!$yes) {
if (!$this->getIo()->confirm(
@@ -80,7 +72,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
$schema = $this->database->schema();
$connection = Database::getConnection($target, $database);
$schema = $connection->schema();
$tables = $schema->findTables('%');
$tableRows = [];
@@ -102,3 +95,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 0;
}
}

0 comments on commit efe17e2

Please sign in to comment.
You can’t perform that action at this time.