Fix migrate script

This commit is contained in:
Matthias Voppichler 2018-05-12 10:04:41 +02:00
parent ccf1c894b4
commit ab4e2bd5a9

View File

@ -73,8 +73,9 @@ def check_migrate(engine) -> None:
if not has_column(cols, 'fee_open'): if not has_column(cols, 'fee_open'):
# Schema migration necessary # Schema migration necessary
engine.execute("create table trades_bak as select * from trades;") engine.execute("drop table if exists trades_bak")
engine.execute("create table trades_bak as select * from trades")
engine.execute("drop table if exists trades")
# let SQLAlchemy create the schema as required # let SQLAlchemy create the schema as required
_DECL_BASE.metadata.create_all(engine) _DECL_BASE.metadata.create_all(engine)
@ -90,11 +91,9 @@ def check_migrate(engine) -> None:
from trades_bak from trades_bak
""") """)
# engine.execute("alter table trades add fee_open float not null") # Reread columns - the above recreated the table!
# engine.execute("alter table trades add fee_close float not null") inspector = inspect(engine)
# # Update fee_open and fee_close with "fee" column values cols = inspector.get_columns('trades')
# engine.execute("update trades set fee_open = fee, fee_close = fee where fee_open is null")
# engine.execute("alter table trades drop fee_close float not null")
if not has_column(cols, 'open_rate_requested'): if not has_column(cols, 'open_rate_requested'):
engine.execute("alter table trades add open_rate_requested float") engine.execute("alter table trades add open_rate_requested float")
@ -102,8 +101,6 @@ def check_migrate(engine) -> None:
engine.execute("alter table trades add close_rate_requested float") engine.execute("alter table trades add close_rate_requested float")
def cleanup() -> None: def cleanup() -> None:
""" """
Flushes all pending operations to disk. Flushes all pending operations to disk.