qewqwe
This commit is contained in:
@@ -217,6 +217,10 @@ final class SchemaManager
|
||||
$this->upgradeMinerOffersTable();
|
||||
$applied[] = 'miner_offers_table';
|
||||
}
|
||||
if (!$this->tableExists($this->prefix . 'offer_basis_history')) {
|
||||
$this->ensureOfferBasisHistoryTable();
|
||||
$applied[] = 'offer_basis_history_table';
|
||||
}
|
||||
if (!$this->tableExists($this->prefix . 'purchased_miners')) {
|
||||
$this->upgradePurchasedMinersTable();
|
||||
$applied[] = 'purchased_miners_table';
|
||||
@@ -337,6 +341,10 @@ final class SchemaManager
|
||||
$this->upgradeMinerOffersTable();
|
||||
$applied[] = 'miner_offers_table';
|
||||
}
|
||||
if (!$this->tableExists($this->prefix . 'offer_basis_history')) {
|
||||
$this->ensureOfferBasisHistoryTable();
|
||||
$applied[] = 'offer_basis_history_table';
|
||||
}
|
||||
|
||||
if (!$this->tableExists($this->prefix . 'purchased_miners')) {
|
||||
$this->upgradePurchasedMinersTable();
|
||||
@@ -693,6 +701,9 @@ final class SchemaManager
|
||||
if (!$this->tableExists($this->prefix . 'miner_offers')) {
|
||||
$upgrades[] = 'miner_offers_table';
|
||||
}
|
||||
if (!$this->tableExists($this->prefix . 'offer_basis_history')) {
|
||||
$upgrades[] = 'offer_basis_history_table';
|
||||
}
|
||||
if (!$this->tableExists($this->prefix . 'purchased_miners')) {
|
||||
$upgrades[] = 'purchased_miners_table';
|
||||
}
|
||||
@@ -1179,6 +1190,45 @@ final class SchemaManager
|
||||
$this->executeUpgradeStatements($statements, 'Schema-Upgrade fuer Miner-Angebote fehlgeschlagen.');
|
||||
}
|
||||
|
||||
private function ensureOfferBasisHistoryTable(): void
|
||||
{
|
||||
if ($this->tableExists($this->prefix . 'offer_basis_history')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$table = $this->prefix . 'offer_basis_history';
|
||||
$projectTable = $this->prefix . 'projects';
|
||||
$statements = $this->driver === 'pgsql'
|
||||
? [
|
||||
'CREATE TABLE IF NOT EXISTS ' . $table . ' (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
project_key VARCHAR(64) NOT NULL,
|
||||
owner_sub VARCHAR(191) NOT NULL DEFAULT \'local\',
|
||||
offer_type VARCHAR(16) NOT NULL,
|
||||
base_price_amount NUMERIC(20,8) NOT NULL,
|
||||
base_price_currency VARCHAR(10) NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_mining_offer_basis_history_project FOREIGN KEY (project_key) REFERENCES ' . $projectTable . '(project_key) ON DELETE CASCADE
|
||||
)',
|
||||
'CREATE INDEX IF NOT EXISTS idx_mining_offer_basis_history_project_owner_type_created ON ' . $table . ' (project_key, owner_sub, offer_type, created_at)',
|
||||
]
|
||||
: [
|
||||
'CREATE TABLE IF NOT EXISTS `' . $table . '` (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
project_key VARCHAR(64) NOT NULL,
|
||||
owner_sub VARCHAR(191) NOT NULL DEFAULT \'local\',
|
||||
offer_type VARCHAR(16) NOT NULL,
|
||||
base_price_amount DECIMAL(20,8) NOT NULL,
|
||||
base_price_currency VARCHAR(10) NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_mining_offer_basis_history_project FOREIGN KEY (project_key) REFERENCES `' . $projectTable . '`(project_key) ON DELETE CASCADE,
|
||||
KEY idx_mining_offer_basis_history_project_owner_type_created (project_key, owner_sub, offer_type, created_at)
|
||||
)',
|
||||
];
|
||||
|
||||
$this->executeUpgradeStatements($statements, 'Schema-Upgrade fuer Angebots-Basis-Historie fehlgeschlagen.');
|
||||
}
|
||||
|
||||
private function upgradePurchasedMinersTable(): void
|
||||
{
|
||||
$table = $this->prefix . 'purchased_miners';
|
||||
@@ -1528,6 +1578,7 @@ final class SchemaManager
|
||||
$this->prefix . 'wallet_snapshots',
|
||||
$this->prefix . 'wallet_withdrawals',
|
||||
$this->prefix . 'miner_offers',
|
||||
$this->prefix . 'offer_basis_history',
|
||||
$this->prefix . 'targets',
|
||||
$this->prefix . 'dashboard_definitions',
|
||||
$this->prefix . 'purchased_miners',
|
||||
|
||||
Reference in New Issue
Block a user