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);
}
}
$this->pdo->commit();
if ($this->pdo->inTransaction()) {
$this->pdo->commit();
}
} catch (MigrationException $e) {
if ($this->pdo->inTransaction()) {
$this->pdo->rollBack();

View File

@ -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