Update migrations for mariadb
This commit is contained in:
parent
c265f39323
commit
3d94d7df5c
@ -98,7 +98,10 @@ def migrate_trades_and_orders_table(
|
|||||||
with engine.begin() as connection:
|
with engine.begin() as connection:
|
||||||
# drop indexes on backup table in new session
|
# drop indexes on backup table in new session
|
||||||
for index in inspector.get_indexes(trade_back_name):
|
for index in inspector.get_indexes(trade_back_name):
|
||||||
connection.execute(text(f"drop index {index['name']}"))
|
if engine.name == 'mysql':
|
||||||
|
connection.execute(text(f"drop index {index['name']} on {trade_back_name}"))
|
||||||
|
else:
|
||||||
|
connection.execute(text(f"drop index {index['name']}"))
|
||||||
|
|
||||||
order_id, trade_id = get_last_sequence_ids(engine, trade_back_name, order_back_name)
|
order_id, trade_id = get_last_sequence_ids(engine, trade_back_name, order_back_name)
|
||||||
|
|
||||||
@ -198,7 +201,8 @@ def check_migrate(engine, decl_base, previous_tables) -> None:
|
|||||||
# Check if migration necessary
|
# Check if migration necessary
|
||||||
# Migrates both trades and orders table!
|
# Migrates both trades and orders table!
|
||||||
if not has_column(cols, 'buy_tag'):
|
if not has_column(cols, 'buy_tag'):
|
||||||
logger.info(f'Running database migration for trades - backup: {table_back_name}')
|
logger.info(f"Running database migration for trades - "
|
||||||
|
f"backup: {table_back_name}, {order_table_bak_name}")
|
||||||
migrate_trades_and_orders_table(
|
migrate_trades_and_orders_table(
|
||||||
decl_base, inspector, engine, table_back_name, cols, order_table_bak_name)
|
decl_base, inspector, engine, table_back_name, cols, order_table_bak_name)
|
||||||
# Reread columns - the above recreated the table!
|
# Reread columns - the above recreated the table!
|
||||||
|
@ -600,7 +600,8 @@ def test_migrate_new(mocker, default_conf, fee, caplog):
|
|||||||
assert trade.stoploss_last_update is None
|
assert trade.stoploss_last_update is None
|
||||||
assert log_has("trying trades_bak1", caplog)
|
assert log_has("trying trades_bak1", caplog)
|
||||||
assert log_has("trying trades_bak2", caplog)
|
assert log_has("trying trades_bak2", caplog)
|
||||||
assert log_has("Running database migration for trades - backup: trades_bak2", caplog)
|
assert log_has("Running database migration for trades - backup: trades_bak2, orders_bak0",
|
||||||
|
caplog)
|
||||||
assert trade.open_trade_value == trade._calc_open_trade_value()
|
assert trade.open_trade_value == trade._calc_open_trade_value()
|
||||||
assert trade.close_profit_abs is None
|
assert trade.close_profit_abs is None
|
||||||
|
|
||||||
@ -733,7 +734,7 @@ def test_migrate_mid_state(mocker, default_conf, fee, caplog):
|
|||||||
assert trade.initial_stop_loss == 0.0
|
assert trade.initial_stop_loss == 0.0
|
||||||
assert trade.open_trade_value == trade._calc_open_trade_value()
|
assert trade.open_trade_value == trade._calc_open_trade_value()
|
||||||
assert log_has("trying trades_bak0", caplog)
|
assert log_has("trying trades_bak0", caplog)
|
||||||
assert log_has("Running database migration for trades - backup: trades_bak0", caplog)
|
assert log_has("Running database migration for trades - backup: trades_bak0, orders_bak0", caplog)
|
||||||
|
|
||||||
|
|
||||||
def test_adjust_stop_loss(fee):
|
def test_adjust_stop_loss(fee):
|
||||||
|
Loading…
Reference in New Issue
Block a user