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

This commit is contained in:
2026-05-05 20:36:41 +02:00
parent fd092ef615
commit eb8b04a621
14 changed files with 39 additions and 969 deletions

View File

@@ -151,14 +151,6 @@ final class Router
$this->respond(['data' => $this->probeFxRates(Http::input())], 200);
}
if ($resource === 'currencies-refresh' && $method === 'POST') {
$this->respond(['data' => $this->refreshCurrencies()], 201);
}
if ($resource === 'currencies-probe' && $method === 'POST') {
$this->respond(['data' => $this->probeCurrencies()], 200);
}
if ($resource === 'fx-history' && $method === 'GET') {
$this->respond(['data' => $this->fxHistory()]);
}
@@ -297,18 +289,6 @@ final class Router
Http::json(['data' => $this->purchaseMiner($projectKey, (int) $matches[1], Http::input())], 201);
}
if ($resource === 'currencies' && $method === 'GET') {
Http::json(['data' => $this->currencies()]);
}
if ($resource === 'currency-aliases' && $method === 'GET') {
Http::json(['data' => $this->currencyAliases()]);
}
if ($resource === 'currency-aliases' && $method === 'POST') {
Http::json(['data' => $this->saveCurrencyAlias(Http::input())], 201);
}
throw new ApiException('Ressource nicht gefunden.', 404, ['resource' => $resource, 'method' => $method]);
} catch (ApiException $exception) {
$this->debug->add('router.handle.api_exception', [
@@ -513,8 +493,6 @@ final class Router
$backup = [
'project' => $this->repository()->getProject($projectKey),
'settings' => $this->safeRead(fn () => $this->repository()->getSettings($projectKey)),
'currencies' => $this->safeRead(fn () => $this->repository()->listCurrencies(), []),
'currency_aliases' => $this->safeRead(fn () => $this->repository()->listCurrencyAliases(), []),
'cost_plans' => $this->safeRead(fn () => $this->repository()->listCostPlans($projectKey), []),
'measurements' => $this->safeRead(fn () => $this->repository()->listAllMeasurements($projectKey), []),
'measurement_rates' => $this->safeRead(fn () => $this->repository()->listMeasurementRates($projectKey), []),
@@ -538,23 +516,6 @@ final class Router
$projectName = is_array($backup['project']) ? ($backup['project']['project_name'] ?? null) : null;
$this->repository()->ensureProject($projectKey, is_string($projectName) ? $projectName : null);
foreach ($backup['currencies'] as $currency) {
$this->repository()->saveCurrency([
'code' => $currency['code'],
'name' => $currency['name'],
'symbol' => $currency['symbol'] ?? null,
'is_active' => !empty($currency['is_active']) ? 1 : 0,
'is_crypto' => !empty($currency['is_crypto']) ? 1 : 0,
'sort_order' => (int) ($currency['sort_order'] ?? 0),
]);
}
foreach ($backup['currency_aliases'] as $alias) {
if (!empty($alias['alias_code']) && !empty($alias['currency_code'])) {
$this->repository()->saveCurrencyAlias((string) $alias['alias_code'], (string) $alias['currency_code']);
}
}
if (is_array($backup['settings'])) {
$this->repository()->saveSettings($projectKey, [
'baseline_measured_at' => $backup['settings']['baseline_measured_at'],
@@ -750,7 +711,6 @@ final class Router
'targets' => count($backup['targets']),
'dashboards' => count($backup['dashboards']),
'miner_offers' => count($backup['miner_offers']),
'currency_aliases' => count($backup['currency_aliases']),
'fx_rates' => $restoredFxRates,
],
]);
@@ -795,20 +755,6 @@ final class Router
return $this->fx()->probeLatestRates($base);
}
private function refreshCurrencies(): array
{
$result = $this->fx()->refreshCurrencyCatalog();
$synced = $this->syncLocalCurrencyCatalogFromFxRates(true);
return $result + [
'local_catalog_synced' => count($synced),
];
}
private function probeCurrencies(): array
{
return $this->fx()->probeCurrencyCatalog();
}
private function fxHistory(): array
{
if (!modules()->isEnabled('fx-rates') || !modules()->hasFunction('fx-rates', 'recent_fetches')) {
@@ -1293,7 +1239,7 @@ final class Router
private function bootstrapMeasurements(string $projectKey, array $settings, string $view): array
{
if (in_array($view, ['settings', 'currencies', 'dashboards'], true)) {
if (in_array($view, ['settings', 'dashboards'], true)) {
return [];
}
@@ -1373,7 +1319,7 @@ final class Router
private function normalizeBootstrapView(string $view): string
{
$normalized = trim(strtolower($view));
return in_array($normalized, ['overview', 'measurements', 'dashboards', 'currencies', 'mining', 'settings'], true)
return in_array($normalized, ['overview', 'measurements', 'dashboards', 'mining', 'settings'], true)
? $normalized
: 'overview';
}
@@ -1475,22 +1421,12 @@ final class Router
return;
}
$knownCodes = array_map(
static fn (array $currency): string => strtoupper((string) ($currency['code'] ?? '')),
$this->currencies()
);
if (in_array($priceCurrency, $knownCodes, true)) {
return;
}
$matched = $this->currencyCatalogEntry($priceCurrency);
$this->repository()->ensureCurrencyCode($priceCurrency, $matched['name'] ?? $priceCurrency);
try {
$this->refreshCurrencies();
} catch (\Throwable) {
// Measurement save must not fail because the external currency sync is unavailable.
if ($this->currencyCatalogEntry($priceCurrency) === null) {
throw new ApiException(
'Waehrung ist im fx-rates Katalog nicht vorhanden.',
422,
['currency' => $priceCurrency]
);
}
}
@@ -1580,25 +1516,7 @@ final class Router
private function currencies(): array
{
$catalog = $this->syncLocalCurrencyCatalogFromFxRates();
return $catalog !== [] ? $catalog : $this->repository()->listCurrencies();
}
private function currencyAliases(): array
{
return $this->repository()->listCurrencyAliases();
}
private function saveCurrencyAlias(array $input): array
{
$aliasCode = strtoupper(trim((string) ($input['alias_code'] ?? '')));
$currencyCode = $this->requiredCurrency($input['currency_code'] ?? null, 'currency_code');
if (!preg_match('/^[A-Z0-9]{3,10}$/', $aliasCode)) {
throw new ApiException('Feld alias_code muss ein gueltiger Waehrungscode sein.', 422);
}
return $this->repository()->saveCurrencyAlias($aliasCode, $currencyCode);
return $this->currencyCatalog();
}
private function minerOffers(string $projectKey): array
@@ -1945,24 +1863,18 @@ final class Router
throw new ApiException("Feld {$field} muss ein gueltiger Waehrungscode sein.", 422);
}
$resolved = $this->repository()->resolveCurrencyCode($currency);
if ($resolved !== null && !empty($resolved['code'])) {
return (string) $resolved['code'];
}
$catalogEntry = $this->currencyCatalogEntry($currency);
if (is_array($catalogEntry)) {
$this->repository()->ensureCurrencyCode($currency, (string) ($catalogEntry['name'] ?? $currency));
return $currency;
}
throw new ApiException(
"Feld {$field} verweist auf keinen vorhandenen Waehrungsrecord.",
"Feld {$field} verweist auf keinen vorhandenen fx-rates Waehrungscode.",
422,
[
'field' => $field,
'missing_currency' => $currency,
'hint' => 'Synchronisiere zuerst den Waehrungskatalog aus fx-rates oder hinterlege einen Alias auf einen bestehenden Waehrungsrecord.',
'hint' => 'Synchronisiere zuerst den Waehrungskatalog im Modul fx-rates.',
'available_currencies' => array_slice(array_map(
static fn (array $item): string => (string) ($item['code'] ?? ''),
$this->currencies()
@@ -1981,10 +1893,15 @@ final class Router
private function assertCurrencyType(string $code, bool $expectedCrypto, string $field): void
{
$this->ensureLocalCurrencyRecord($code);
$resolved = $this->repository()->resolveCurrencyCode($code);
$currency = is_array($resolved) ? ($resolved['currency'] ?? null) : null;
$isCrypto = !empty($currency['is_crypto']);
if ($this->currencyCatalogEntry($code) === null) {
throw new ApiException(
"Feld {$field} verweist auf keinen vorhandenen fx-rates Waehrungscode.",
422,
['field' => $field, 'currency' => $code]
);
}
$isCrypto = $this->isCryptoCurrencyCode($code);
if ($isCrypto !== $expectedCrypto) {
throw new ApiException(
$expectedCrypto
@@ -2248,22 +2165,6 @@ final class Router
return null;
}
private function syncLocalCurrencyCatalogFromFxRates(bool $forceRefresh = false): array
{
if ($forceRefresh) {
$this->fxRatesSettingsCache = null;
$this->currencyCatalogCache = null;
}
$catalog = $this->currencyCatalog();
if ($catalog === []) {
return [];
}
$this->repository()->saveCurrencies($catalog);
return $this->repository()->listCurrencies();
}
private function syncFxRatesPreferredCurrencies(array $preferredCurrencies): void
{
if (!modules()->isEnabled('fx-rates') || !modules()->hasFunction('fx-rates', 'save_runtime_settings')) {
@@ -2274,22 +2175,7 @@ final class Router
'preferred_currencies' => $preferredCurrencies,
]);
$this->fxRatesSettingsCache = null;
}
private function ensureLocalCurrencyRecord(string $code): void
{
$resolved = $this->repository()->resolveCurrencyCode($code);
if ($resolved !== null) {
return;
}
$catalogEntry = $this->currencyCatalogEntry($code);
if ($catalogEntry !== null) {
$this->repository()->saveCurrency($catalogEntry);
return;
}
$this->repository()->ensureCurrencyCode($code, $code);
$this->currencyCatalogCache = null;
}
private function isCryptoCurrencyCode(string $code): bool

View File

@@ -310,13 +310,6 @@ final class FxService
return $shared->refreshCurrencyCatalog();
}
if ($this->repository === null) {
return [
'synced_count' => 0,
'currencies' => [],
];
}
$payload = $this->fetchCurrenciesPayload();
$items = is_array($payload['currencies'] ?? null) ? $payload['currencies'] : [];
if ($items === []) {
@@ -349,8 +342,6 @@ final class FxService
$sortOrder++;
}
$this->repository->saveCurrencies($synced);
usort($synced, static function (array $left, array $right): int {
return [$left['sort_order'], $left['code']] <=> [$right['sort_order'], $right['code']];
});
@@ -796,16 +787,7 @@ final class FxService
private function defaultCurrencies(): array
{
if ($this->repository === null) {
return ['EUR', 'USD'];
}
try {
$currencies = $this->repository->listActiveFiatCurrencies();
return array_map(static fn (array $currency): string => (string) $currency['code'], $currencies);
} catch (\Throwable) {
return ['EUR', 'USD'];
}
return ['EUR', 'USD'];
}
private function normalizeRateDate(mixed $value): string

View File

@@ -22,9 +22,6 @@ final class SeedImporter
}
$this->repository->ensureProject($projectKey, SeedData::projectName());
foreach (SeedData::currencies() as $currency) {
$this->repository->saveCurrency($currency);
}
$this->repository->saveSettings($projectKey, SeedData::settings());
$insertedMeasurements = 0;
@@ -60,7 +57,6 @@ final class SeedImporter
'historical_rows_total' => count(SeedData::measurements()),
'targets_synced' => $targetCount,
'dashboards_synced' => $dashboardCount,
'currencies_synced' => count(SeedData::currencies()),
];
}
}

View File

@@ -111,231 +111,6 @@ final class MiningRepository
]);
}
public function listCurrencies(): array
{
$this->debug?->add('db.listCurrencies.start');
$stmt = $this->pdo->query(
'SELECT * FROM ' . $this->table('currencies') . ' WHERE ' . ($this->driver === 'pgsql' ? 'is_active = TRUE' : 'is_active = 1') . ' ORDER BY sort_order ASC, code ASC'
);
$rows = $this->normalizeRows($stmt->fetchAll() ?: []);
$this->debug?->add('db.listCurrencies.end', ['rows' => count($rows)]);
return $rows;
}
public function listCurrencyAliases(): array
{
$stmt = $this->pdo->query(
'SELECT
a.alias_code,
a.currency_code,
c.name AS currency_name,
a.created_at
FROM ' . $this->table('currency_aliases') . ' a
INNER JOIN ' . $this->table('currencies') . ' c ON c.code = a.currency_code
ORDER BY a.alias_code ASC'
);
return $this->normalizeRows($stmt->fetchAll() ?: []);
}
public function resolveCurrencyCode(string $code): ?array
{
$normalizedCode = strtoupper(trim($code));
if ($normalizedCode === '') {
return null;
}
$currencyStmt = $this->pdo->prepare('SELECT * FROM ' . $this->table('currencies') . ' WHERE code = :code LIMIT 1');
$currencyStmt->execute(['code' => $normalizedCode]);
$currency = $currencyStmt->fetch();
if (is_array($currency)) {
return [
'input_code' => $normalizedCode,
'code' => $normalizedCode,
'matched_via' => 'code',
'currency' => $this->normalizeRow($currency),
];
}
if (!$this->tableExists('currency_aliases')) {
return null;
}
$aliasStmt = $this->pdo->prepare(
'SELECT
a.alias_code,
a.currency_code,
c.name AS currency_name,
c.symbol AS currency_symbol,
c.is_active,
c.sort_order
FROM ' . $this->table('currency_aliases') . ' a
INNER JOIN ' . $this->table('currencies') . ' c ON c.code = a.currency_code
WHERE a.alias_code = :alias_code
LIMIT 1'
);
$aliasStmt->execute(['alias_code' => $normalizedCode]);
$alias = $aliasStmt->fetch();
if (!is_array($alias)) {
return null;
}
return [
'input_code' => $normalizedCode,
'code' => (string) $alias['currency_code'],
'matched_via' => 'alias',
'alias_code' => (string) $alias['alias_code'],
'currency' => $this->normalizeRow([
'code' => $alias['currency_code'],
'name' => $alias['currency_name'],
'symbol' => $alias['currency_symbol'] ?? null,
'is_active' => $alias['is_active'] ?? 1,
'sort_order' => $alias['sort_order'] ?? 1000,
]),
];
}
public function saveCurrencyAlias(string $aliasCode, string $currencyCode): array
{
$normalizedAlias = strtoupper(trim($aliasCode));
$normalizedCurrency = strtoupper(trim($currencyCode));
$stmt = $this->pdo->prepare($this->driver === 'pgsql'
? 'INSERT INTO ' . $this->table('currency_aliases') . ' (alias_code, currency_code)
VALUES (:alias_code, :currency_code)
ON CONFLICT (alias_code) DO UPDATE SET currency_code = EXCLUDED.currency_code
RETURNING *'
: 'INSERT INTO ' . $this->table('currency_aliases') . ' (alias_code, currency_code)
VALUES (:alias_code, :currency_code)
ON DUPLICATE KEY UPDATE currency_code = VALUES(currency_code)'
);
$stmt->execute([
'alias_code' => $normalizedAlias,
'currency_code' => $normalizedCurrency,
]);
if ($this->driver === 'pgsql') {
$row = $stmt->fetch();
return is_array($row) ? $this->normalizeRow($row) : ['alias_code' => $normalizedAlias, 'currency_code' => $normalizedCurrency];
}
return ['alias_code' => $normalizedAlias, 'currency_code' => $normalizedCurrency];
}
public function saveCurrency(array $currency): void
{
$this->debug?->add('db.saveCurrency.start', ['code' => $currency['code'] ?? null]);
$stmt = $this->pdo->prepare($this->driver === 'pgsql'
? 'INSERT INTO ' . $this->table('currencies') . ' (code, name, symbol, is_active, is_crypto, sort_order)
VALUES (:code, :name, :symbol, :is_active, :is_crypto, :sort_order)
ON CONFLICT (code) DO UPDATE SET
name = EXCLUDED.name,
symbol = EXCLUDED.symbol,
is_active = EXCLUDED.is_active,
is_crypto = EXCLUDED.is_crypto,
sort_order = EXCLUDED.sort_order'
: 'INSERT INTO ' . $this->table('currencies') . ' (code, name, symbol, is_active, is_crypto, sort_order)
VALUES (:code, :name, :symbol, :is_active, :is_crypto, :sort_order)
ON DUPLICATE KEY UPDATE
name = VALUES(name),
symbol = VALUES(symbol),
is_active = VALUES(is_active),
is_crypto = VALUES(is_crypto),
sort_order = VALUES(sort_order)'
);
$stmt->execute([
'code' => $currency['code'],
'name' => $currency['name'],
'symbol' => $currency['symbol'],
'is_active' => $currency['is_active'],
'is_crypto' => $currency['is_crypto'] ?? 0,
'sort_order' => $currency['sort_order'],
]);
$this->debug?->add('db.saveCurrency.end', ['code' => $currency['code'] ?? null]);
}
public function saveCurrencies(array $currencies): int
{
if ($currencies === []) {
return 0;
}
$this->debug?->add('db.saveCurrencies.start', ['count' => count($currencies)]);
$statement = $this->pdo->prepare($this->driver === 'pgsql'
? 'INSERT INTO ' . $this->table('currencies') . ' (code, name, symbol, is_active, is_crypto, sort_order)
VALUES (:code, :name, :symbol, :is_active, :is_crypto, :sort_order)
ON CONFLICT (code) DO UPDATE SET
name = EXCLUDED.name,
symbol = EXCLUDED.symbol,
is_active = EXCLUDED.is_active,
is_crypto = EXCLUDED.is_crypto,
sort_order = EXCLUDED.sort_order'
: 'INSERT INTO ' . $this->table('currencies') . ' (code, name, symbol, is_active, is_crypto, sort_order)
VALUES (:code, :name, :symbol, :is_active, :is_crypto, :sort_order)
ON DUPLICATE KEY UPDATE
name = VALUES(name),
symbol = VALUES(symbol),
is_active = VALUES(is_active),
is_crypto = VALUES(is_crypto),
sort_order = VALUES(sort_order)'
);
$count = 0;
$startedTransaction = false;
if (!$this->pdo->inTransaction()) {
$this->pdo->beginTransaction();
$startedTransaction = true;
}
try {
foreach ($currencies as $currency) {
if (!is_array($currency) || empty($currency['code'])) {
continue;
}
$statement->execute([
'code' => $currency['code'],
'name' => $currency['name'] ?? $currency['code'],
'symbol' => $currency['symbol'] ?? $currency['code'],
'is_active' => $currency['is_active'] ?? 1,
'is_crypto' => $currency['is_crypto'] ?? 0,
'sort_order' => $currency['sort_order'] ?? 1000,
]);
$count++;
}
if ($startedTransaction) {
$this->pdo->commit();
}
$this->debug?->add('db.saveCurrencies.end', ['count' => $count]);
} catch (\Throwable $exception) {
if ($startedTransaction && $this->pdo->inTransaction()) {
$this->pdo->rollBack();
}
$this->debug?->add('db.saveCurrencies.error', ['message' => $exception->getMessage()]);
throw $exception;
}
return $count;
}
public function ensureCurrencyCode(string $code, ?string $name = null): void
{
$normalizedCode = strtoupper(trim($code));
if ($normalizedCode === '') {
return;
}
$this->saveCurrency([
'code' => substr($normalizedCode, 0, 10),
'name' => $name !== null && trim($name) !== '' ? trim($name) : $normalizedCode,
'symbol' => substr($normalizedCode, 0, 8),
'is_active' => 1,
'is_crypto' => $this->isCryptoCode($normalizedCode) ? 1 : 0,
'sort_order' => 1000,
]);
}
public function tableExists(string $logicalName): bool
{
$tableName = $this->table($logicalName);
@@ -1099,32 +874,6 @@ final class MiningRepository
return ['fetch' => null, 'rates' => []];
}
$currenciesToEnsure = [
[
'code' => substr($baseCurrency, 0, 10),
'name' => $baseCurrency,
'symbol' => substr($baseCurrency, 0, 8),
'is_active' => 1,
'is_crypto' => $this->isCryptoCode($baseCurrency) ? 1 : 0,
'sort_order' => 1000,
],
];
foreach (array_keys($rates) as $currencyCode) {
$normalizedCurrencyCode = strtoupper(trim((string) $currencyCode));
if ($normalizedCurrencyCode === '') {
continue;
}
$currenciesToEnsure[] = [
'code' => substr($normalizedCurrencyCode, 0, 10),
'name' => $normalizedCurrencyCode,
'symbol' => substr($normalizedCurrencyCode, 0, 8),
'is_active' => 1,
'is_crypto' => $this->isCryptoCode($normalizedCurrencyCode) ? 1 : 0,
'sort_order' => 1000,
];
}
$this->saveCurrencies($currenciesToEnsure);
if ($this->driver === 'pgsql') {
$fetchStmt = $this->pdo->prepare(
'INSERT INTO ' . $this->table('fx_fetches') . ' (
@@ -1247,16 +996,6 @@ final class MiningRepository
$provider = trim($provider) !== '' ? trim($provider) : 'currencyapi';
$fetchedAt = $this->currentUtcTimestamp();
$normalizedRates = [];
$currenciesToEnsure = [
[
'code' => substr($baseCurrency, 0, 10),
'name' => $baseCurrency,
'symbol' => substr($baseCurrency, 0, 8),
'is_active' => 1,
'is_crypto' => $this->isCryptoCode($baseCurrency) ? 1 : 0,
'sort_order' => 1000,
],
];
foreach ($rates as $currencyCode => $rate) {
if (!is_numeric($rate)) {
@@ -1269,14 +1008,6 @@ final class MiningRepository
}
$normalizedRates[$normalizedCurrencyCode] = (float) $rate;
$currenciesToEnsure[] = [
'code' => substr($normalizedCurrencyCode, 0, 10),
'name' => $normalizedCurrencyCode,
'symbol' => substr($normalizedCurrencyCode, 0, 8),
'is_active' => 1,
'is_crypto' => $this->isCryptoCode($normalizedCurrencyCode) ? 1 : 0,
'sort_order' => 1000,
];
}
$this->debug?->add('db.saveFxFetch.start', [
@@ -1304,14 +1035,6 @@ final class MiningRepository
}
try {
$this->debug?->add('db.saveFxFetch.saveCurrencies.start', [
'currency_count' => count($currenciesToEnsure),
]);
$this->saveCurrencies($currenciesToEnsure);
$this->debug?->add('db.saveFxFetch.saveCurrencies.end', [
'currency_count' => count($currenciesToEnsure),
]);
if ($this->driver === 'pgsql') {
$this->debug?->add('db.saveFxFetch.insertFetch.start', [
'driver' => $this->driver,
@@ -1459,21 +1182,10 @@ final class MiningRepository
}
}
public function listActiveFiatCurrencies(): array
{
$currencies = $this->listCurrencies();
return array_values(array_filter($currencies, static function (array $currency): bool {
$code = strtoupper((string) ($currency['code'] ?? ''));
return $code !== '' && empty($currency['is_crypto']);
}));
}
private function table(string $logicalName): string
{
return match ($logicalName) {
'projects' => $this->prefix . 'projects',
'currencies' => $this->prefix . 'currencies',
'settings' => $this->prefix . 'settings',
'cost_plans' => $this->prefix . 'cost_plans',
'measurements' => $this->prefix . 'measurements',

View File

@@ -213,18 +213,6 @@ final class SchemaManager
$this->upgradeTargetOfferColumn();
$applied[] = 'target_offer_column';
}
if (!$this->tableExists($this->prefix . 'currency_aliases')) {
$this->ensureCurrencyAliasesTable();
$applied[] = 'currency_aliases_table';
}
if ($this->tableExists($this->prefix . 'currencies') && !$this->columnExists($this->prefix . 'currencies', 'is_crypto')) {
$this->upgradeCurrenciesClassificationColumns();
$applied[] = 'currency_classification';
}
if ($this->tableExists($this->prefix . 'currencies')) {
$this->ensureCurrencyForeignKeys();
$applied[] = 'currency_foreign_keys';
}
if ($this->tableExists($this->prefix . 'miner_offers') && (
!$this->columnExists($this->prefix . 'miner_offers', 'base_price_amount') ||
!$this->columnExists($this->prefix . 'miner_offers', 'base_price_currency') ||
@@ -264,7 +252,6 @@ final class SchemaManager
{
$coreTables = [
$this->prefix . 'projects',
$this->prefix . 'currencies',
$this->prefix . 'settings',
$this->prefix . 'cost_plans',
$this->prefix . 'measurements',
@@ -335,18 +322,6 @@ final class SchemaManager
$this->upgradeTargetOfferColumn();
$applied[] = 'target_offer_column';
}
if (!$this->tableExists($this->prefix . 'currency_aliases')) {
$this->ensureCurrencyAliasesTable();
$applied[] = 'currency_aliases_table';
}
if ($this->tableExists($this->prefix . 'currencies') && !$this->columnExists($this->prefix . 'currencies', 'is_crypto')) {
$this->upgradeCurrenciesClassificationColumns();
$applied[] = 'currency_classification';
}
if ($this->tableExists($this->prefix . 'currencies')) {
$this->ensureCurrencyForeignKeys();
$applied[] = 'currency_foreign_keys';
}
if ($this->tableExists($this->prefix . 'miner_offers') && (
!$this->columnExists($this->prefix . 'miner_offers', 'base_price_amount') ||
!$this->columnExists($this->prefix . 'miner_offers', 'base_price_currency') ||
@@ -788,36 +763,6 @@ final class SchemaManager
$this->ensureMeasurementRatesTable();
$this->ensurePayoutsTable();
$this->ensureMinerTables();
$this->ensureCurrencyAliasesTable();
}
public function ensureCurrencyAliasesTable(): void
{
if ($this->tableExists($this->prefix . 'currency_aliases')) {
return;
}
$table = $this->prefix . 'currency_aliases';
$currencyTable = $this->prefix . 'currencies';
$statements = $this->driver === 'pgsql'
? [
'CREATE TABLE IF NOT EXISTS ' . $table . ' (
alias_code VARCHAR(10) PRIMARY KEY,
currency_code VARCHAR(10) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_mining_currency_aliases_currency FOREIGN KEY (currency_code) REFERENCES ' . $currencyTable . '(code) ON DELETE CASCADE
)',
]
: [
'CREATE TABLE IF NOT EXISTS `' . $table . '` (
alias_code VARCHAR(10) NOT NULL PRIMARY KEY,
currency_code VARCHAR(10) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_mining_currency_aliases_currency FOREIGN KEY (currency_code) REFERENCES `' . $currencyTable . '`(code) ON DELETE CASCADE
)',
];
$this->executeUpgradeStatements($statements, 'Schema-Upgrade fuer Waehrungs-Aliase fehlgeschlagen.');
}
public function ensureMeasurementRatesTable(): void
@@ -1361,7 +1306,6 @@ final class SchemaManager
{
return [
$this->prefix . 'projects',
$this->prefix . 'currencies',
$this->prefix . 'settings',
$this->prefix . 'cost_plans',
$this->prefix . 'measurements',
@@ -1379,7 +1323,6 @@ final class SchemaManager
$this->prefix . 'payouts',
$this->prefix . 'miner_offers',
$this->prefix . 'purchased_miners',
$this->prefix . 'currency_aliases',
];
}
@@ -1392,8 +1335,6 @@ final class SchemaManager
{
return [
$this->prefix . 'projects',
$this->prefix . 'currencies',
$this->prefix . 'currency_aliases',
$this->prefix . 'settings',
$this->prefix . 'cost_plans',
$this->prefix . 'measurements',