From 13aa62878eb787099e1c2c4c4d2881cd6c05e700 Mon Sep 17 00:00:00 2001 From: natsoni Date: Tue, 16 Apr 2024 10:47:44 +0200 Subject: [PATCH 1/2] Revert commits abdb27af and 727208ff --- backend/src/api/database-migration.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/backend/src/api/database-migration.ts b/backend/src/api/database-migration.ts index f1d68c621..df5091701 100644 --- a/backend/src/api/database-migration.ts +++ b/backend/src/api/database-migration.ts @@ -652,11 +652,6 @@ class DatabaseMigration { await this.$executeQuery('ALTER TABLE `prices` ADD `THB` float DEFAULT "-1"'); await this.$executeQuery('ALTER TABLE `prices` ADD `TRY` float DEFAULT "-1"'); await this.$executeQuery('ALTER TABLE `prices` ADD `ZAR` float DEFAULT "-1"'); - - await this.$executeQuery('TRUNCATE hashrates'); - await this.$executeQuery('TRUNCATE difficulty_adjustments'); - await this.$executeQuery(`UPDATE state SET string = NULL WHERE name = 'pools_json_sha'`); - await this.updateToSchemaVersion(75); } From 1c55eef27688b22b9b177cafb8257ece11c897ff Mon Sep 17 00:00:00 2001 From: natsoni Date: Tue, 16 Apr 2024 22:43:13 +0200 Subject: [PATCH 2/2] Move table re-index to own migrations --- backend/src/api/database-migration.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/backend/src/api/database-migration.ts b/backend/src/api/database-migration.ts index df5091701..3ddf1dcc7 100644 --- a/backend/src/api/database-migration.ts +++ b/backend/src/api/database-migration.ts @@ -7,7 +7,7 @@ import cpfpRepository from '../repositories/CpfpRepository'; import { RowDataPacket } from 'mysql2'; class DatabaseMigration { - private static currentVersion = 78; + private static currentVersion = 81; private queryTimeout = 3600_000; private statisticsAddedIndexed = false; private uniqueLogs: string[] = []; @@ -669,6 +669,21 @@ class DatabaseMigration { await this.$executeQuery('ALTER TABLE `prices` CHANGE `time` `time` datetime NOT NULL'); await this.updateToSchemaVersion(78); } + + if (databaseSchemaVersion < 79 && isBitcoin === true) { + await this.$executeQuery('TRUNCATE hashrates'); + await this.updateToSchemaVersion(79); + } + + if (databaseSchemaVersion < 80 && isBitcoin === true) { + await this.$executeQuery('TRUNCATE difficulty_adjustments'); + await this.updateToSchemaVersion(80); + } + + if (databaseSchemaVersion < 81 && isBitcoin === true) { + await this.$executeQuery(`UPDATE state SET string = NULL WHERE name = 'pools_json_sha'`); + await this.updateToSchemaVersion(81); + } } /**