From af186c633c81beff56aa909f6c944f66457e0162 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sat, 10 May 2025 17:29:38 +0000 Subject: [PATCH] db migration to reindex blocks since first annex tx --- backend/src/api/database-migration.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/src/api/database-migration.ts b/backend/src/api/database-migration.ts index cce639370..fbaf05658 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 = 97; + private static currentVersion = 98; private queryTimeout = 3600_000; private statisticsAddedIndexed = false; private uniqueLogs: string[] = []; @@ -1146,6 +1146,14 @@ class DatabaseMigration { await this.$executeQuery(`ALTER TABLE blocks MODIFY COLUMN definition_hash varchar(255) NULL DEFAULT "${poolJsonSha}"`); await this.updateToSchemaVersion(97); } + + // reindex mainnet Goggles flags for mined block templates above height 896070 + // (since the first annex transaction at height 896071) + // (safe to make this conditional on the network since it doesn't change the database schema) + if (databaseSchemaVersion < 98 && config.MEMPOOL.NETWORK === 'mainnet') { + await this.$executeQuery('UPDATE blocks_summaries SET version = 0 WHERE height >= 896070;'); + await this.updateToSchemaVersion(98); + } } /**