From 42a800e791c9d1405815d96b192f2b0942a42bcc Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Fri, 12 Nov 2021 00:19:06 +0100 Subject: [PATCH] Fixing database "name" (=path) for SQLite Since DBAL 3.0 (see https://github.com/doctrine/migrations/pull/1028), the message currently reads for SQLite: > Careful, database "" will be purged. Do you want to continue? (yes/no) Neither @Ocramius (see https://github.com/doctrine/dbal/pull/3606#discussion_r292713610) nor me (see https://github.com/doctrine/dbal/pull/4982) succeeded in convincing @morozov to continue returning the file path ;-) So it looks like the fix needs to be done here... Suggestion: What about adding the platform too? So the message would be: > Careful, MySQL database "foo" will be purged. Do you want to continue? (yes/no) `doctrine/migrations` is currently broken too: > WARNING! You are about to execute a migration in database "" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]: So when done here, I'm going to submit the same there (i.e. follow up of https://github.com/doctrine/migrations/pull/1028) --- Command/LoadDataFixturesDoctrineCommand.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Command/LoadDataFixturesDoctrineCommand.php b/Command/LoadDataFixturesDoctrineCommand.php index c9279b2..3d72ff0 100644 --- a/Command/LoadDataFixturesDoctrineCommand.php +++ b/Command/LoadDataFixturesDoctrineCommand.php @@ -103,7 +103,13 @@ protected function execute(InputInterface $input, OutputInterface $output) assert($em instanceof EntityManagerInterface); if (! $input->getOption('append')) { - if (! $ui->confirm(sprintf('Careful, database "%s" will be purged. Do you want to continue?', $em->getConnection()->getDatabase()), ! $input->isInteractive())) { + if ('sqlite' === $em->getConnection()->getDatabasePlatform()->getName()) { + $params = $em->getConnection()->getParams(); + $database = $params['path']; + } else { + $database = $em->getConnection()->getDatabase(); + } + if (! $ui->confirm(sprintf('Careful, database "%s" will be purged. Do you want to continue?', $database), ! $input->isInteractive())) { return 0; } }