diff --git a/alembic/versions/8dd169389646_.py b/alembic/versions/8dd169389646_.py new file mode 100644 index 0000000..af8ecbd --- /dev/null +++ b/alembic/versions/8dd169389646_.py @@ -0,0 +1,56 @@ +"""empty message + +Revision ID: 8dd169389646 +Revises: 29c9ff4e6926 +Create Date: 2021-07-02 11:44:43.666306 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "8dd169389646" +down_revision = "29c9ff4e6926" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("pair", "token1_volume") + op.drop_column("pair", "token0_volume") + op.drop_column("token", "trade_volume") + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column( + "token", + sa.Column( + "trade_volume", + sa.NUMERIC(precision=34, scale=0), + autoincrement=False, + nullable=True, + ), + ) + op.add_column( + "pair", + sa.Column( + "token0_volume", + sa.NUMERIC(precision=34, scale=0), + autoincrement=False, + nullable=True, + ), + ) + op.add_column( + "pair", + sa.Column( + "token1_volume", + sa.NUMERIC(precision=34, scale=0), + autoincrement=False, + nullable=True, + ), + ) + # ### end Alembic commands ### diff --git a/alembic/versions/e3e1a25cae68_.py b/alembic/versions/e3e1a25cae68_.py new file mode 100644 index 0000000..065710d --- /dev/null +++ b/alembic/versions/e3e1a25cae68_.py @@ -0,0 +1,32 @@ +"""empty message + +Revision ID: e3e1a25cae68 +Revises: 8dd169389646 +Create Date: 2021-07-02 11:47:57.854369 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "e3e1a25cae68" +down_revision = "8dd169389646" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column("pair", sa.Column("token0_volume", sa.Numeric(), nullable=True)) + op.add_column("pair", sa.Column("token1_volume", sa.Numeric(), nullable=True)) + op.add_column("token", sa.Column("trade_volume", sa.Numeric(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("token", "trade_volume") + op.drop_column("pair", "token1_volume") + op.drop_column("pair", "token0_volume") + # ### end Alembic commands ### diff --git a/models.py b/models.py index b8ea753..d7e5027 100644 --- a/models.py +++ b/models.py @@ -21,7 +21,7 @@ class Token(Base): symbol = Column(String(8), nullable=False) name = Column(String(128), nullable=False) decimals = Column(Integer, nullable=False) - trade_volume = Column(Numeric(34)) + trade_volume = Column(Numeric()) class Pair(Base): @@ -39,8 +39,8 @@ class Pair(Base): foreign_keys=[token1_id], backref=backref("pairs1", uselist=True, cascade="delete,all"), ) - token0_volume = Column(Numeric(34)) - token1_volume = Column(Numeric(34)) + token0_volume = Column(Numeric()) + token1_volume = Column(Numeric()) class Swap(Base): diff --git a/processing.py b/processing.py index 06ae26d..fa5c0e1 100644 --- a/processing.py +++ b/processing.py @@ -59,6 +59,8 @@ def process_swap_transaction(timestamp, extrinsicEvents, ex_dict): for event in extrinsicEvents: if event["event_id"] == "SwapSuccess": swap_success = True + elif event["event_id"] == "ExtrinsicFailed": + swap_success = False elif event["event_id"] == "Exchange": input_amount = event["params"][4]["value"] output_amount = event["params"][5]["value"]