From 929ddb13728b2ca0b4002a00998a4df73b639511 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Thu, 25 Jun 2020 23:21:33 +0200 Subject: [PATCH 01/10] Update MigrateCommand.php Adding the name of the database to CLI's yes/no question, analogous to https://github.com/doctrine/DoctrineFixturesBundle/blob/master/Command/LoadDataFixturesDoctrineCommand.php#L103 TODO: Do the same in `ExecuteCommand` and `RollupCommand` --- .../Migrations/Tools/Console/Command/MigrateCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php index bcbe45c8da..8d8b7ed859 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php @@ -121,7 +121,7 @@ protected function execute(InputInterface $input, OutputInterface $output) : int $migratorConfigurationFactory = $this->getDependencyFactory()->getConsoleInputMigratorConfigurationFactory(); $migratorConfiguration = $migratorConfigurationFactory->getMigratorConfiguration($input); - $question = 'WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue?'; + $question = sprintf('WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', $this->getDependencyFactory()->getConnection()->getDatabase()); if (! $migratorConfiguration->isDryRun() && ! $this->canExecute($question, $input)) { $this->io->error('Migration cancelled!'); From f29a90594f836896f8367bc766b3ec3573d990ac Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Sun, 28 Jun 2020 22:56:25 +0200 Subject: [PATCH 02/10] Update ExecuteCommand.php See https://github.com/doctrine/migrations/pull/1028#discussion_r446630901 --- .../Migrations/Tools/Console/Command/ExecuteCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php index 3893f2370e..3ae6658bef 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php @@ -105,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output) : int $migratorConfigurationFactory = $this->getDependencyFactory()->getConsoleInputMigratorConfigurationFactory(); $migratorConfiguration = $migratorConfigurationFactory->getMigratorConfiguration($input); - $question = 'WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue?'; + $question = sprintf('WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', $this->getDependencyFactory()->getConnection()->getDatabase()); if (! $migratorConfiguration->isDryRun() && ! $this->canExecute($question, $input)) { $this->io->error('Migration cancelled!'); From 69a3358049e6dcf3b9a77e3bcdd93feaf18911fd Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Sun, 28 Jun 2020 22:56:29 +0200 Subject: [PATCH 03/10] Update RollupCommand.php See https://github.com/doctrine/migrations/pull/1028#discussion_r446630901 --- lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php index fa114a1d11..ce97835f46 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php @@ -37,7 +37,7 @@ protected function configure() : void protected function execute(InputInterface $input, OutputInterface $output) : int { - $question = 'WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue?'; + $question = sprintf('WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', $this->getDependencyFactory()->getConnection()->getDatabase()); if (! $this->canExecute($question, $input)) { $this->io->error('Migration cancelled!'); From 50992593f347e9953e7cdf4c18cb4366335b05d6 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Mon, 29 Jun 2020 22:15:03 +0200 Subject: [PATCH 04/10] Update lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Grégoire Paris --- .../Migrations/Tools/Console/Command/ExecuteCommand.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php index 3ae6658bef..4c7e434b44 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php @@ -105,7 +105,10 @@ protected function execute(InputInterface $input, OutputInterface $output) : int $migratorConfigurationFactory = $this->getDependencyFactory()->getConsoleInputMigratorConfigurationFactory(); $migratorConfiguration = $migratorConfigurationFactory->getMigratorConfiguration($input); - $question = sprintf('WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', $this->getDependencyFactory()->getConnection()->getDatabase()); + $question = sprintf( + 'WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', + $this->getDependencyFactory()->getConnection()->getDatabase() + ); if (! $migratorConfiguration->isDryRun() && ! $this->canExecute($question, $input)) { $this->io->error('Migration cancelled!'); From e4eb34df410abe2e8daa80ffff1d27289da894a0 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Mon, 29 Jun 2020 22:15:24 +0200 Subject: [PATCH 05/10] Update lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Grégoire Paris --- .../Migrations/Tools/Console/Command/MigrateCommand.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php index 8d8b7ed859..f02ccf3ba5 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php @@ -121,7 +121,10 @@ protected function execute(InputInterface $input, OutputInterface $output) : int $migratorConfigurationFactory = $this->getDependencyFactory()->getConsoleInputMigratorConfigurationFactory(); $migratorConfiguration = $migratorConfigurationFactory->getMigratorConfiguration($input); - $question = sprintf('WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', $this->getDependencyFactory()->getConnection()->getDatabase()); + $question = sprintf( + 'WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', + $this->getDependencyFactory()->getConnection()->getDatabase() + ); if (! $migratorConfiguration->isDryRun() && ! $this->canExecute($question, $input)) { $this->io->error('Migration cancelled!'); From 4e3707bf9f334d5b42e6e588bfa263eacce046ed Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Mon, 29 Jun 2020 22:15:34 +0200 Subject: [PATCH 06/10] Update lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Grégoire Paris --- .../Migrations/Tools/Console/Command/RollupCommand.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php index ce97835f46..513a917bb5 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php @@ -37,7 +37,10 @@ protected function configure() : void protected function execute(InputInterface $input, OutputInterface $output) : int { - $question = sprintf('WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', $this->getDependencyFactory()->getConnection()->getDatabase()); + $question = sprintf( + 'WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', + $this->getDependencyFactory()->getConnection()->getDatabase() + ); if (! $this->canExecute($question, $input)) { $this->io->error('Migration cancelled!'); From 60447688d14faf76b48a3873e2a8e39f74d38bf2 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Thu, 2 Jul 2020 14:40:22 +0200 Subject: [PATCH 07/10] Update ExecuteCommand.php See https://github.com/doctrine/migrations/pull/1028#issuecomment-652964992 --- .../Migrations/Tools/Console/Command/ExecuteCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php index 4c7e434b44..63b83938dc 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/ExecuteCommand.php @@ -107,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output) : int $question = sprintf( 'WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', - $this->getDependencyFactory()->getConnection()->getDatabase() + $this->getDependencyFactory()->getConnection()->getDatabase() ?? '' ); if (! $migratorConfiguration->isDryRun() && ! $this->canExecute($question, $input)) { $this->io->error('Migration cancelled!'); From 7ec206e1012395042936bf4ad06ddc37e6e0f303 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Thu, 2 Jul 2020 14:40:52 +0200 Subject: [PATCH 08/10] Update MigrateCommand.php --- .../Migrations/Tools/Console/Command/MigrateCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php index f02ccf3ba5..df5d693070 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/MigrateCommand.php @@ -123,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output) : int $question = sprintf( 'WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', - $this->getDependencyFactory()->getConnection()->getDatabase() + $this->getDependencyFactory()->getConnection()->getDatabase() ?? '' ); if (! $migratorConfiguration->isDryRun() && ! $this->canExecute($question, $input)) { $this->io->error('Migration cancelled!'); From 71da2523ad302aebd83659b87ef2c5c12f0ee900 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Thu, 2 Jul 2020 14:41:04 +0200 Subject: [PATCH 09/10] Update RollupCommand.php --- lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php b/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php index 513a917bb5..b6334a0088 100644 --- a/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php +++ b/lib/Doctrine/Migrations/Tools/Console/Command/RollupCommand.php @@ -39,7 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output) : int { $question = sprintf( 'WARNING! You are about to execute a migration in database "%s" that could result in schema changes and data loss. Are you sure you wish to continue?', - $this->getDependencyFactory()->getConnection()->getDatabase() + $this->getDependencyFactory()->getConnection()->getDatabase() ?? '' ); if (! $this->canExecute($question, $input)) { From 9517c32c8ba2a5430b043a31aa7f6badea9ed818 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Fri, 3 Jul 2020 13:19:21 +0200 Subject: [PATCH 10/10] Update MigrateCommandTest.php See https://github.com/doctrine/migrations/pull/1028#issuecomment-653391372 --- .../Tests/Tools/Console/Command/MigrateCommandTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrateCommandTest.php b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrateCommandTest.php index 7730500fb5..71a5ec6f91 100644 --- a/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrateCommandTest.php +++ b/tests/Doctrine/Migrations/Tests/Tools/Console/Command/MigrateCommandTest.php @@ -403,7 +403,7 @@ public function testExecuteMigrateCancelExecutedUnavailableMigrations() : void $output = $this->migrateCommandTester->getDisplay(true); self::assertStringContainsString('[WARNING] You have 1 previously executed migrations in the database that are not registered migrations.', $output); - self::assertStringContainsString('WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue?', $output); + self::assertStringContainsString('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?', $output); self::assertStringContainsString('[ERROR] Migration cancelled!', $output); self::assertSame(3, $this->migrateCommandTester->getStatusCode()); @@ -423,7 +423,7 @@ public function testExecuteMigrateCancel() : void $output = $this->migrateCommandTester->getDisplay(true); - self::assertStringContainsString('WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue?', $output); + self::assertStringContainsString('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?', $output); self::assertStringContainsString('[ERROR] Migration cancelled!', $output); self::assertSame(3, $this->migrateCommandTester->getStatusCode());