Skip to content

EspoCRM – Open Source CRM Application

Migration not changing version

Yurii2a509b2ddc56
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);
+ }
}