From 2a509b2ddc56e0a68b5ceb1acc0febb356287fdb Mon Sep 17 00:00:00 2001 From: Yurii Date: Thu, 30 Apr 2026 17:36:56 +0300 Subject: [PATCH] Migration not changing version --- .../Espo/Core/Upgrades/Migration/Runner.php | 7 ++ .../Core/Upgrades/Migration/RunnerTest.php | 76 ++++++++++++++++++- 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/application/Espo/Core/Upgrades/Migration/Runner.php b/application/Espo/Core/Upgrades/Migration/Runner.php index a1618814b6..eae90f790f 100644 --- a/application/Espo/Core/Upgrades/Migration/Runner.php +++ b/application/Espo/Core/Upgrades/Migration/Runner.php @@ -71,6 +71,13 @@ class Runner if ($afterSteps === []) { $io->writeLine("No migrations to run."); + if ($version !== $targetVersion) { + $this->updateVersion($targetVersion); + $this->dataManager->updateAppTimestamp(); + + $io->writeLine("Completed."); + } + return; } diff --git a/tests/unit/Espo/Core/Upgrades/Migration/RunnerTest.php b/tests/unit/Espo/Core/Upgrades/Migration/RunnerTest.php index 9ca78c1f42..b16213e7d7 100644 --- a/tests/unit/Espo/Core/Upgrades/Migration/RunnerTest.php +++ b/tests/unit/Espo/Core/Upgrades/Migration/RunnerTest.php @@ -59,7 +59,7 @@ class RunnerTest extends TestCase $this->configWriter = $this->createMock(ConfigWriter::class); } - public function testRun(): void + public function testRunMigration(): void { $this->versionDataProvider ->expects($this->once()) @@ -114,4 +114,78 @@ class RunnerTest extends TestCase /** @noinspection PhpUnhandledExceptionInspection */ $runner->run($this->io); } + + public function testRunNoMigration(): void + { + $this->versionDataProvider + ->expects($this->once()) + ->method('getTargetVersion') + ->willReturn('9.3.4'); + + $this->versionDataProvider + ->expects($this->once()) + ->method('getPreviousVersion') + ->willReturn('9.2.7'); + + + $this->stepsRunner + ->expects($this->never()) + ->method('runPrepare'); + + $this->stepsRunner + ->expects($this->never()) + ->method('runAfterUpgrade'); + + $this->configWriter + ->expects($this->once()) + ->method('set') + ->with('version', '9.3.4'); + + $runner = new Runner( + $this->stepsProvider, + $this->versionDataProvider, + $this->stepsRunner, + $this->dataManager, + $this->configWriter + ); + + /** @noinspection PhpUnhandledExceptionInspection */ + $runner->run($this->io); + } + + public function testRunSameVersion(): void + { + $this->versionDataProvider + ->expects($this->once()) + ->method('getTargetVersion') + ->willReturn('9.3.4'); + + $this->versionDataProvider + ->expects($this->once()) + ->method('getPreviousVersion') + ->willReturn('9.3.4'); + + $this->stepsRunner + ->expects($this->never()) + ->method('runPrepare'); + + $this->stepsRunner + ->expects($this->never()) + ->method('runAfterUpgrade'); + + $this->configWriter + ->expects($this->never()) + ->method('set'); + + $runner = new Runner( + $this->stepsProvider, + $this->versionDataProvider, + $this->stepsRunner, + $this->dataManager, + $this->configWriter + ); + + /** @noinspection PhpUnhandledExceptionInspection */ + $runner->run($this->io); + } }