From 5830da24c0bb5950e11b472339318b628d976de3 Mon Sep 17 00:00:00 2001 From: Alejandro Ibarra Date: Mon, 10 Jun 2024 15:51:55 +0200 Subject: [PATCH] Add migration version and name to pending actions error (#2289) --- src/Phinx/Migration/AbstractMigration.php | 2 +- tests/Phinx/Migration/AbstractMigrationTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Phinx/Migration/AbstractMigration.php b/src/Phinx/Migration/AbstractMigration.php index 9cecf0c7e..050480f59 100644 --- a/src/Phinx/Migration/AbstractMigration.php +++ b/src/Phinx/Migration/AbstractMigration.php @@ -358,7 +358,7 @@ public function postFlightCheck(): void { foreach ($this->tables as $table) { if ($table->hasPendingActions()) { - throw new RuntimeException('Migration has pending actions after execution!'); + throw new RuntimeException(sprintf('Migration %s_%s has pending actions after execution!', $this->getVersion(), $this->getName())); } } } diff --git a/tests/Phinx/Migration/AbstractMigrationTest.php b/tests/Phinx/Migration/AbstractMigrationTest.php index 6304fb68b..1af5e2121 100644 --- a/tests/Phinx/Migration/AbstractMigrationTest.php +++ b/tests/Phinx/Migration/AbstractMigrationTest.php @@ -265,7 +265,7 @@ public function testTableMethod() public function testPostFlightCheckFail() { // stub migration - $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', ['mockenv', 20230102030405]); + $migrationStub = $this->getMockForAbstractClass('\Phinx\Migration\AbstractMigration', ['mockenv', 20230102030405], 'PostFlightCheck'); $adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\MysqlAdapter') ->setConstructorArgs([[]]) @@ -280,7 +280,7 @@ public function testPostFlightCheckFail() $table->addColumn('column1', 'integer', ['null' => true]); $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('Migration has pending actions after execution!'); + $this->expectExceptionMessage('Migration 20230102030405_PostFlightCheck has pending actions after execution!'); $migrationStub->postFlightCheck(); }