Add sequence migration

This commit is contained in:
Matthias
2022-05-10 07:13:51 +02:00
parent 269630e755
commit 31cce741ac
2 changed files with 21 additions and 1 deletions

View File

@@ -46,7 +46,7 @@ def get_last_sequence_ids(engine, trade_back_name, order_back_name):
return order_id, trade_id
def set_sequence_ids(engine, order_id, trade_id):
def set_sequence_ids(engine, order_id, trade_id, pairlock_id=None):
if engine.name == 'postgresql':
with engine.begin() as connection:
@@ -54,6 +54,9 @@ def set_sequence_ids(engine, order_id, trade_id):
connection.execute(text(f"ALTER SEQUENCE orders_id_seq RESTART WITH {order_id}"))
if trade_id:
connection.execute(text(f"ALTER SEQUENCE trades_id_seq RESTART WITH {trade_id}"))
if pairlock_id:
connection.execute(
text(f"ALTER SEQUENCE pairlocks_id_seq RESTART WITH {pairlock_id}"))
def drop_index_on_table(engine, inspector, table_bak_name):