From 4b330dff6ceea56bf8e74787974fbb5f4c318ab1 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Fri, 21 Nov 2025 11:03:58 +0200 Subject: [PATCH] Adds the option to run next DB migration(s) one by one --- app/core/MigrationRunner.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/core/MigrationRunner.php b/app/core/MigrationRunner.php index d48e3ba..201cf9b 100644 --- a/app/core/MigrationRunner.php +++ b/app/core/MigrationRunner.php @@ -127,16 +127,29 @@ class MigrationRunner } public function applyPendingMigrations(): array + { + return $this->runMigrations($this->listPendingMigrations()); + } + + public function applyNextMigration(): array { $pending = $this->listPendingMigrations(); - $appliedNow = []; if (empty($pending)) { + return []; + } + return $this->runMigrations([reset($pending)]); + } + + private function runMigrations(array $migrations): array + { + $appliedNow = []; + if (empty($migrations)) { return $appliedNow; } try { $this->pdo->beginTransaction(); - foreach ($pending as $migration) { + foreach ($migrations as $migration) { $path = $this->migrationsDir . '/' . $migration; $sql = file_get_contents($path); if ($sql === false) {