From 82fb01384ffd023f8831948846c7284765c16891 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Fri, 21 Nov 2025 21:09:14 +0200 Subject: [PATCH] Fixes for the db migration routine --- app/core/MigrationRunner.php | 4 +++- app/pages/admin-tools.php | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/core/MigrationRunner.php b/app/core/MigrationRunner.php index 8819367..7c27d4a 100644 --- a/app/core/MigrationRunner.php +++ b/app/core/MigrationRunner.php @@ -213,7 +213,9 @@ class MigrationRunner throw new MigrationException($migration, $migrationException->getMessage(), $migrationException); } } - $this->pdo->commit(); + if ($this->pdo->inTransaction()) { + $this->pdo->commit(); + } } catch (MigrationException $e) { if ($this->pdo->inTransaction()) { $this->pdo->rollBack(); diff --git a/app/pages/admin-tools.php b/app/pages/admin-tools.php index 86bbd3b..8a9dc68 100644 --- a/app/pages/admin-tools.php +++ b/app/pages/admin-tools.php @@ -242,16 +242,21 @@ try { $all = array_unique(array_merge($pending, $applied)); foreach ($all as $fname) { $path = realpath($migrationsDir . '/' . $fname); + $content = false; if ($path && strpos($path, realpath($migrationsDir)) === 0) { $content = @file_get_contents($path); - if ($content !== false) { - $migration_contents[$fname] = $content; - } } + $record = $runner->getMigrationRecord($fname); if ($record) { $migration_records[$fname] = $record; } + + if ($content !== false && $content !== null) { + $migration_contents[$fname] = $content; + } elseif (!empty($record['content'])) { + $migration_contents[$fname] = $record['content']; + } } } catch (Throwable $e) { // show error in the page