asdasd
This commit is contained in:
@@ -184,6 +184,10 @@ final class SchemaManager
|
||||
$this->upgradeSettingsPreferredCurrenciesColumn();
|
||||
$applied[] = 'settings_preferences';
|
||||
}
|
||||
if ($this->tableExists($this->prefix . 'measurements') && !$this->columnExists($this->prefix . 'measurements', 'fx_fetch_id')) {
|
||||
$this->ensureMeasurementFxReferenceColumn();
|
||||
$applied[] = 'measurement_fx_reference';
|
||||
}
|
||||
|
||||
if (!$this->tableExists($this->prefix . 'measurement_rates')) {
|
||||
$this->ensureMeasurementRatesTable();
|
||||
@@ -298,6 +302,10 @@ final class SchemaManager
|
||||
$this->upgradeSettingsPreferredCurrenciesColumn();
|
||||
$applied[] = 'settings_preferences';
|
||||
}
|
||||
if ($this->tableExists($this->prefix . 'measurements') && !$this->columnExists($this->prefix . 'measurements', 'fx_fetch_id')) {
|
||||
$this->ensureMeasurementFxReferenceColumn();
|
||||
$applied[] = 'measurement_fx_reference';
|
||||
}
|
||||
|
||||
if (!$this->tableExists($this->prefix . 'fx_fetches') || !$this->tableExists($this->prefix . 'fx_rates')) {
|
||||
$this->ensureFxRatesTable();
|
||||
@@ -404,6 +412,40 @@ final class SchemaManager
|
||||
$this->ensureLegacyMinerOfferImportColumns();
|
||||
}
|
||||
|
||||
private function ensureMeasurementFxReferenceColumn(): void
|
||||
{
|
||||
$table = $this->prefix . 'measurements';
|
||||
if (!$this->tableExists($table)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$statements = $this->driver === 'pgsql'
|
||||
? [
|
||||
'ALTER TABLE ' . $table . ' ADD COLUMN IF NOT EXISTS fx_fetch_id BIGINT',
|
||||
'CREATE INDEX IF NOT EXISTS idx_miningcheck_measurements_fx_fetch ON ' . $table . ' (fx_fetch_id)',
|
||||
]
|
||||
: [
|
||||
'ALTER TABLE `' . $table . '` ADD COLUMN fx_fetch_id BIGINT UNSIGNED NULL',
|
||||
'ALTER TABLE `' . $table . '` ADD INDEX idx_miningcheck_measurements_fx_fetch (fx_fetch_id)',
|
||||
];
|
||||
|
||||
foreach ($statements as $statement) {
|
||||
try {
|
||||
$this->executeUpgradeStatements([$statement], 'Messpunkt-FX-Referenz konnte nicht angelegt werden.');
|
||||
} catch (\Throwable $exception) {
|
||||
$message = strtolower($exception->getMessage());
|
||||
if (
|
||||
($this->driver === 'mysql' && (str_contains($message, 'duplicate column') || str_contains($message, 'duplicate key name'))) ||
|
||||
($this->driver === 'pgsql' && str_contains($message, 'already exists'))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function ensureLegacyMinerOfferImportColumns(): void
|
||||
{
|
||||
$table = $this->prefix . 'miner_offers';
|
||||
@@ -579,6 +621,10 @@ final class SchemaManager
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->tableExists($this->prefix . 'measurements') && !$this->columnExists($this->prefix . 'measurements', 'fx_fetch_id')) {
|
||||
$upgrades[] = 'measurement_fx_reference';
|
||||
}
|
||||
|
||||
if (!$this->tableExists($this->prefix . 'fx_fetches') || !$this->tableExists($this->prefix . 'fx_rates')) {
|
||||
$upgrades[] = 'fx_rates_table';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user