asdasd
This commit is contained in:
@@ -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,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user