diff --git a/backend/src/api/database-migration.ts b/backend/src/api/database-migration.ts index 3932179ed..f79b1a104 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 = 111; + private static currentVersion = 112; private queryTimeout = 3600_000; private statisticsAddedIndexed = false; private uniqueLogs: string[] = []; @@ -1255,6 +1255,23 @@ class DatabaseMigration { await this.$executeQuery('ALTER TABLE `compact_cpfp_clusters` ADD template_algo TINYINT UNSIGNED NOT NULL DEFAULT 0'); await this.updateToSchemaVersion(111); } + + if (databaseSchemaVersion < 112 && isBitcoin === true) { + // Per-block minimum fee-merit effective fee rate (issue #6639). The computation + // version handles algorithm changes; the acceleration-set snapshot lets the + // bounded pull sweep detect late-arriving accelerations without producer-side + // writes. + await this.$executeQuery(` + ALTER TABLE blocks + ADD min_fee_rate DOUBLE UNSIGNED NULL DEFAULT NULL, + ADD min_fee_rate_version TINYINT UNSIGNED NOT NULL DEFAULT 0, + ADD min_fee_rate_acceleration_count SMALLINT UNSIGNED NOT NULL DEFAULT 0, + ADD min_fee_rate_acceleration_fingerprint CHAR(64) NOT NULL DEFAULT '', + ADD min_fee_rate_computed_at TIMESTAMP NULL DEFAULT NULL, + ADD INDEX min_fee_rate_backfill (stale, min_fee_rate_version, min_fee_rate_computed_at) + `); + await this.updateToSchemaVersion(112); + } } /**