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