asdasd
All checks were successful
Deploy / deploy-production (push) Has been skipped
Deploy / deploy-staging (push) Successful in 6s

This commit is contained in:
2026-04-11 02:40:45 +02:00
parent c15c90bf6d
commit bbd2e39f86
3 changed files with 33 additions and 82 deletions

View File

@@ -379,20 +379,39 @@ final class SchemaManager
$sql = (string) file_get_contents($schemaFile);
$statements = preg_split('/;\s*(?:\R|$)/', $sql) ?: [];
$currentStatement = null;
$useTransaction = $this->driver === 'pgsql' && !$this->pdo->inTransaction();
try {
if ($useTransaction) {
$this->pdo->beginTransaction();
}
foreach ($statements as $statement) {
$trimmed = trim($statement);
if ($trimmed === '') {
continue;
}
$currentStatement = $trimmed;
$this->pdo->exec($trimmed);
}
if ($useTransaction && $this->pdo->inTransaction()) {
$this->pdo->commit();
}
} catch (\Throwable $exception) {
if ($useTransaction && $this->pdo->inTransaction()) {
$this->pdo->rollBack();
}
throw new ApiException(
'Schema-Import fuer Mining-Checker fehlgeschlagen.',
500,
['message' => $exception->getMessage()]
[
'message' => $exception->getMessage(),
'schema_file' => $schemaFile,
'statement' => $currentStatement !== null ? substr($currentStatement, 0, 1000) : null,
]
);
}
}