From 85af9dd3fc3f9b39d5d8ebecd28a4c6a5a6f6a27 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 21 Apr 2026 07:01:39 +0200 Subject: [PATCH] fix: migrate wallet_history table --- freqtrade/commands/db_commands.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/freqtrade/commands/db_commands.py b/freqtrade/commands/db_commands.py index d5acf8f14..3e20741ea 100644 --- a/freqtrade/commands/db_commands.py +++ b/freqtrade/commands/db_commands.py @@ -17,6 +17,7 @@ def start_convert_db(args: dict[str, Any]) -> None: from freqtrade.persistence.key_value_store import _KeyValueStoreModel from freqtrade.persistence.migrations import set_sequence_ids from freqtrade.persistence.pairlock import PairLock + from freqtrade.persistence.wallet_history import WalletHistory config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) @@ -29,6 +30,7 @@ def start_convert_db(args: dict[str, Any]) -> None: pairlock_count = 0 kv_count = 0 custom_data_count = 0 + wallet_history_count = 0 for trade in Trade.get_trades(): trade_count += 1 make_transient(trade) @@ -57,12 +59,19 @@ def start_convert_db(args: dict[str, Any]) -> None: session_target.add(cd) session_target.commit() + for wh in WalletHistory.session.scalars(select(WalletHistory)): + wallet_history_count += 1 + make_transient(wh) + session_target.add(wh) + session_target.commit() + # Update sequences max_trade_id = session_target.scalar(select(func.max(Trade.id))) max_order_id = session_target.scalar(select(func.max(Order.id))) max_pairlock_id = session_target.scalar(select(func.max(PairLock.id))) max_kv_id = session_target.scalar(select(func.max(_KeyValueStoreModel.id))) max_custom_data_id = session_target.scalar(select(func.max(_CustomData.id))) + max_wallet_history_id = session_target.scalar(select(func.max(WalletHistory.id))) set_sequence_ids( session_target.get_bind(), @@ -71,9 +80,11 @@ def start_convert_db(args: dict[str, Any]) -> None: pairlock_id=(max_pairlock_id or 0) + 1, kv_id=(max_kv_id or 0) + 1, custom_data_id=(max_custom_data_id or 0) + 1, + wallet_history_id=(max_wallet_history_id or 0) + 1, ) logger.info( f"Migrated {trade_count} Trades, {pairlock_count} Pairlocks, " - f"{kv_count} Key-Value pairs, and {custom_data_count} Custom Data entries." + f"{kv_count} Key-Value pairs, {custom_data_count} Custom Data entries, " + f"and {wallet_history_count} Wallet History entries." )