diff --git a/core/lib/Drupal/Core/Command/DbDumpApplication.php b/core/lib/Drupal/Core/Command/DbDumpApplication.php index d14d3bb..080e20f 100644 --- a/core/lib/Drupal/Core/Command/DbDumpApplication.php +++ b/core/lib/Drupal/Core/Command/DbDumpApplication.php @@ -49,7 +49,7 @@ function __construct(Connection $connection, ModuleHandlerInterface $module_hand * {@inheritdoc} */ protected function getCommandName(InputInterface $input) { - return 'dump-database-d8'; + return 'dump-database-d8-mysql'; } /** diff --git a/core/lib/Drupal/Core/Command/DbDumpCommand.php b/core/lib/Drupal/Core/Command/DbDumpCommand.php index c6b6758..e34513d 100644 --- a/core/lib/Drupal/Core/Command/DbDumpCommand.php +++ b/core/lib/Drupal/Core/Command/DbDumpCommand.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Command; +use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Variable; use Drupal\Core\Database\Connection; use Drupal\Core\Extension\ModuleHandlerInterface; @@ -21,9 +22,10 @@ * for tables denoted as schema-only). The resulting script creates the tables * and populates them with the exported data. * - * This command is currently only compatible with MySQL. Making it backend- - * agnostic will require \Drupal\Core\Database\Schema support the ability - * to retrieve table schema information. + * @todo This command is currently only compatible with MySQL. Making it + * backend-agnostic will require \Drupal\Core\Database\Schema support the + * ability to retrieve table schema information. + * @see https://www.drupal.org/node/301038 * * @see \Drupal\Core\Command\DbDumpApplication */ @@ -68,6 +70,11 @@ class DbDumpCommand extends Command { * The module handler to use. */ function __construct(Connection $connection, ModuleHandlerInterface $module_handler) { + // Check this is MySQL. + if ($connection->databaseType() !== 'mysql') { + throw new \RuntimeException('This script can only be used with MySQL database backends.'); + } + $this->connection = $connection; $this->moduleHandler = $module_handler; parent::__construct(); @@ -77,7 +84,7 @@ function __construct(Connection $connection, ModuleHandlerInterface $module_hand * {@inheritdoc} */ protected function configure() { - $this->setName('dump-database-d8') + $this->setName('dump-database-d8-mysql') ->setDescription('Dump the current database to a generation script'); } diff --git a/core/modules/system/src/Tests/Update/DbDumpTest.php b/core/modules/system/src/Tests/Update/DbDumpTest.php index 678ac82..d82a992 100644 --- a/core/modules/system/src/Tests/Update/DbDumpTest.php +++ b/core/modules/system/src/Tests/Update/DbDumpTest.php @@ -78,7 +78,7 @@ public function setUp() { parent::setUp(); // Determine what database backend is running, and set the skip flag. - $this->skipTests = !(Database::getConnection() instanceof Connection); + $this->skipTests = Database::getConnection()->databaseType() !== 'mysql'; // Create some schemas so our export contains tables. $this->installSchema('system', ['sessions', 'url_alias']); @@ -105,7 +105,7 @@ public function testDbDumpCommand() { } $application = new DbDumpApplication(Database::getConnection(), $this->container->get('module_handler')); - $command = $application->find('dump-database-d8'); + $command = $application->find('dump-database-d8-mysql'); $command_tester = new CommandTester($command); $command_tester->execute([]); @@ -143,7 +143,7 @@ public function testScriptLoad() { // Generate the script. $application = new DbDumpApplication(Database::getConnection(), $this->container->get('module_handler')); - $command = $application->find('dump-database-d8'); + $command = $application->find('dump-database-d8-mysql'); $command_tester = new CommandTester($command); $command_tester->execute([]); $script = $command_tester->getDisplay(); diff --git a/core/scripts/dump-database-d8.php b/core/scripts/dump-database-d8-mysql.php similarity index 100% rename from core/scripts/dump-database-d8.php rename to core/scripts/dump-database-d8-mysql.php