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

This commit is contained in:
2026-04-11 03:33:07 +02:00
parent 94f3295b6c
commit dc7373fc08

View File

@@ -377,6 +377,8 @@ final class SchemaManager
throw new ApiException($exception->getMessage(), 422); throw new ApiException($exception->getMessage(), 422);
} }
$this->prepareSchemaForSqlImport();
$statementCount = $this->executeSqlContent((string) $file['sql'], (string) $file['file']); $statementCount = $this->executeSqlContent((string) $file['sql'], (string) $file['file']);
return [ return [
@@ -386,6 +388,58 @@ final class SchemaManager
]; ];
} }
private function prepareSchemaForSqlImport(): void
{
$status = $this->schemaStatus();
if (!$status['all_present']) {
$this->initializeSchema(false);
}
$this->upgradeSchemaDirect();
$this->ensureLegacyImportCompatibility();
}
private function ensureLegacyImportCompatibility(): void
{
$this->ensureLegacyMinerOfferImportColumns();
}
private function ensureLegacyMinerOfferImportColumns(): void
{
$table = $this->prefix . 'miner_offers';
if (!$this->tableExists($table)) {
return;
}
$statements = $this->driver === 'pgsql'
? [
'ALTER TABLE ' . $table . ' ADD COLUMN IF NOT EXISTS price_amount NUMERIC(20,8)',
'ALTER TABLE ' . $table . ' ADD COLUMN IF NOT EXISTS price_currency VARCHAR(10)',
'ALTER TABLE ' . $table . ' ADD COLUMN IF NOT EXISTS usd_reference_amount NUMERIC(20,8)',
'ALTER TABLE ' . $table . ' ADD COLUMN IF NOT EXISTS reference_price_amount NUMERIC(20,8)',
'ALTER TABLE ' . $table . ' ADD COLUMN IF NOT EXISTS reference_price_currency VARCHAR(10)',
]
: [
'ALTER TABLE `' . $table . '` ADD COLUMN price_amount DECIMAL(20,8) NULL',
'ALTER TABLE `' . $table . '` ADD COLUMN price_currency VARCHAR(10) NULL',
'ALTER TABLE `' . $table . '` ADD COLUMN usd_reference_amount DECIMAL(20,8) NULL',
'ALTER TABLE `' . $table . '` ADD COLUMN reference_price_amount DECIMAL(20,8) NULL',
'ALTER TABLE `' . $table . '` ADD COLUMN reference_price_currency VARCHAR(10) NULL',
];
foreach ($statements as $statement) {
try {
$this->executeUpgradeStatements([$statement], 'Import-Kompatibilitaet fuer Miner-Angebote fehlgeschlagen.');
} catch (\Throwable $exception) {
if ($this->driver === 'mysql' && str_contains(strtolower($exception->getMessage()), 'duplicate column')) {
continue;
}
throw $exception;
}
}
}
private function tableExists(string $table): bool private function tableExists(string $table): bool
{ {
return in_array($table, $this->existingTables([$table]), true); return in_array($table, $this->existingTables([$table]), true);