Fixes for the db migration routine

main
Yasen Pramatarov 2025-11-21 21:09:14 +02:00
parent 65a4dc7f18
commit 82fb01384f
2 changed files with 11 additions and 4 deletions

View File

@ -213,7 +213,9 @@ class MigrationRunner
throw new MigrationException($migration, $migrationException->getMessage(), $migrationException); throw new MigrationException($migration, $migrationException->getMessage(), $migrationException);
} }
} }
if ($this->pdo->inTransaction()) {
$this->pdo->commit(); $this->pdo->commit();
}
} catch (MigrationException $e) { } catch (MigrationException $e) {
if ($this->pdo->inTransaction()) { if ($this->pdo->inTransaction()) {
$this->pdo->rollBack(); $this->pdo->rollBack();

View File

@ -242,16 +242,21 @@ try {
$all = array_unique(array_merge($pending, $applied)); $all = array_unique(array_merge($pending, $applied));
foreach ($all as $fname) { foreach ($all as $fname) {
$path = realpath($migrationsDir . '/' . $fname); $path = realpath($migrationsDir . '/' . $fname);
$content = false;
if ($path && strpos($path, realpath($migrationsDir)) === 0) { if ($path && strpos($path, realpath($migrationsDir)) === 0) {
$content = @file_get_contents($path); $content = @file_get_contents($path);
if ($content !== false) {
$migration_contents[$fname] = $content;
}
} }
$record = $runner->getMigrationRecord($fname); $record = $runner->getMigrationRecord($fname);
if ($record) { if ($record) {
$migration_records[$fname] = $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) { } catch (Throwable $e) {
// show error in the page // show error in the page