Skip to content

Commit f0ab857

Browse files
authored
Merge pull request HemeraProtocol#176 from HemeraProtocol/chore/lint_fix
Lint fix
2 parents 9ba1ed2 + 7cba519 commit f0ab857

File tree

1 file changed

+83
-58
lines changed

1 file changed

+83
-58
lines changed

migrations/versions/20240927_add_merchant_moe_table.py

Lines changed: 83 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,83 +5,108 @@
55
Create Date: 2024-09-27 17:00:46.320469
66
77
"""
8+
89
from typing import Sequence, Union
910

10-
from alembic import op
1111
import sqlalchemy as sa
12+
from alembic import op
1213
from sqlalchemy.dialects import postgresql
1314

1415
# revision identifiers, used by Alembic.
15-
revision: str = '67015d9fa59b'
16-
down_revision: Union[str, None] = 'c609922eae7a'
16+
revision: str = "67015d9fa59b"
17+
down_revision: Union[str, None] = "c609922eae7a"
1718
branch_labels: Union[str, Sequence[str], None] = None
1819
depends_on: Union[str, Sequence[str], None] = None
1920

2021

2122
def upgrade() -> None:
2223
# ### commands auto generated by Alembic - please adjust! ###
23-
op.create_table('af_merchant_moe_pool_data_current',
24-
sa.Column('pool_address', postgresql.BYTEA(), nullable=False),
25-
sa.Column('block_timestamp', sa.BIGINT(), nullable=True),
26-
sa.Column('block_number', sa.BIGINT(), nullable=True),
27-
sa.Column('active_id', sa.BIGINT(), nullable=True),
28-
sa.Column('bin_step', sa.BIGINT(), nullable=True),
29-
sa.Column('create_time', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=True),
30-
sa.Column('update_time', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=True),
31-
sa.Column('reorg', sa.BOOLEAN(), nullable=True),
32-
sa.PrimaryKeyConstraint('pool_address')
24+
op.create_table(
25+
"af_merchant_moe_pool_data_current",
26+
sa.Column("pool_address", postgresql.BYTEA(), nullable=False),
27+
sa.Column("block_timestamp", sa.BIGINT(), nullable=True),
28+
sa.Column("block_number", sa.BIGINT(), nullable=True),
29+
sa.Column("active_id", sa.BIGINT(), nullable=True),
30+
sa.Column("bin_step", sa.BIGINT(), nullable=True),
31+
sa.Column("create_time", postgresql.TIMESTAMP(), server_default=sa.text("now()"), nullable=True),
32+
sa.Column("update_time", postgresql.TIMESTAMP(), server_default=sa.text("now()"), nullable=True),
33+
sa.Column("reorg", sa.BOOLEAN(), nullable=True),
34+
sa.PrimaryKeyConstraint("pool_address"),
35+
)
36+
op.create_table(
37+
"af_merchant_moe_pool_data_hist",
38+
sa.Column("pool_address", postgresql.BYTEA(), nullable=False),
39+
sa.Column("block_timestamp", sa.BIGINT(), nullable=False),
40+
sa.Column("block_number", sa.BIGINT(), nullable=False),
41+
sa.Column("active_id", sa.BIGINT(), nullable=True),
42+
sa.Column("bin_step", sa.BIGINT(), nullable=True),
43+
sa.Column("create_time", postgresql.TIMESTAMP(), server_default=sa.text("now()"), nullable=True),
44+
sa.Column("update_time", postgresql.TIMESTAMP(), server_default=sa.text("now()"), nullable=True),
45+
sa.Column("reorg", sa.BOOLEAN(), nullable=True),
46+
sa.PrimaryKeyConstraint("pool_address", "block_timestamp", "block_number"),
47+
)
48+
op.create_table(
49+
"af_staked_fbtc_current",
50+
sa.Column("vault_address", postgresql.BYTEA(), nullable=False),
51+
sa.Column("wallet_address", postgresql.BYTEA(), nullable=False),
52+
sa.Column("block_number", sa.BIGINT(), nullable=True),
53+
sa.Column("block_timestamp", sa.BIGINT(), nullable=True),
54+
sa.Column("amount", sa.NUMERIC(precision=100), nullable=True),
55+
sa.Column("changed_amount", sa.NUMERIC(precision=100), nullable=True),
56+
sa.Column("protocol_id", sa.VARCHAR(), nullable=True),
57+
sa.Column("create_time", postgresql.TIMESTAMP(), server_default=sa.text("now()"), nullable=True),
58+
sa.Column("update_time", postgresql.TIMESTAMP(), server_default=sa.text("now()"), nullable=True),
59+
sa.PrimaryKeyConstraint("vault_address", "wallet_address"),
60+
)
61+
op.create_index(
62+
"af_staked_fbtc_current_protocol_block_desc_index",
63+
"af_staked_fbtc_current",
64+
[sa.text("protocol_id DESC")],
65+
unique=False,
66+
)
67+
op.create_index(
68+
"af_staked_fbtc_current_wallet_block_desc_index",
69+
"af_staked_fbtc_current",
70+
[sa.text("wallet_address DESC")],
71+
unique=False,
3372
)
34-
op.create_table('af_merchant_moe_pool_data_hist',
35-
sa.Column('pool_address', postgresql.BYTEA(), nullable=False),
36-
sa.Column('block_timestamp', sa.BIGINT(), nullable=False),
37-
sa.Column('block_number', sa.BIGINT(), nullable=False),
38-
sa.Column('active_id', sa.BIGINT(), nullable=True),
39-
sa.Column('bin_step', sa.BIGINT(), nullable=True),
40-
sa.Column('create_time', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=True),
41-
sa.Column('update_time', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=True),
42-
sa.Column('reorg', sa.BOOLEAN(), nullable=True),
43-
sa.PrimaryKeyConstraint('pool_address', 'block_timestamp', 'block_number')
73+
op.create_table(
74+
"af_staked_fbtc_detail_hist",
75+
sa.Column("vault_address", postgresql.BYTEA(), nullable=False),
76+
sa.Column("wallet_address", postgresql.BYTEA(), nullable=False),
77+
sa.Column("block_number", sa.BIGINT(), nullable=False),
78+
sa.Column("block_timestamp", sa.BIGINT(), nullable=False),
79+
sa.Column("amount", sa.NUMERIC(precision=100), nullable=True),
80+
sa.Column("changed_amount", sa.NUMERIC(precision=100), nullable=True),
81+
sa.Column("protocol_id", sa.VARCHAR(), nullable=True),
82+
sa.Column("create_time", postgresql.TIMESTAMP(), server_default=sa.text("now()"), nullable=True),
83+
sa.Column("update_time", postgresql.TIMESTAMP(), server_default=sa.text("now()"), nullable=True),
84+
sa.Column("reorg", sa.BOOLEAN(), nullable=True),
85+
sa.PrimaryKeyConstraint("vault_address", "wallet_address", "block_timestamp", "block_number"),
4486
)
45-
op.create_table('af_staked_fbtc_current',
46-
sa.Column('vault_address', postgresql.BYTEA(), nullable=False),
47-
sa.Column('wallet_address', postgresql.BYTEA(), nullable=False),
48-
sa.Column('block_number', sa.BIGINT(), nullable=True),
49-
sa.Column('block_timestamp', sa.BIGINT(), nullable=True),
50-
sa.Column('amount', sa.NUMERIC(precision=100), nullable=True),
51-
sa.Column('changed_amount', sa.NUMERIC(precision=100), nullable=True),
52-
sa.Column('protocol_id', sa.VARCHAR(), nullable=True),
53-
sa.Column('create_time', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=True),
54-
sa.Column('update_time', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=True),
55-
sa.PrimaryKeyConstraint('vault_address', 'wallet_address')
87+
op.create_index(
88+
"af_staked_fbtc_detail_hist_protocol_block_desc_index",
89+
"af_staked_fbtc_detail_hist",
90+
[sa.text("protocol_id DESC"), sa.text("block_timestamp DESC")],
91+
unique=False,
5692
)
57-
op.create_index('af_staked_fbtc_current_protocol_block_desc_index', 'af_staked_fbtc_current', [sa.text('protocol_id DESC')], unique=False)
58-
op.create_index('af_staked_fbtc_current_wallet_block_desc_index', 'af_staked_fbtc_current', [sa.text('wallet_address DESC')], unique=False)
59-
op.create_table('af_staked_fbtc_detail_hist',
60-
sa.Column('vault_address', postgresql.BYTEA(), nullable=False),
61-
sa.Column('wallet_address', postgresql.BYTEA(), nullable=False),
62-
sa.Column('block_number', sa.BIGINT(), nullable=False),
63-
sa.Column('block_timestamp', sa.BIGINT(), nullable=False),
64-
sa.Column('amount', sa.NUMERIC(precision=100), nullable=True),
65-
sa.Column('changed_amount', sa.NUMERIC(precision=100), nullable=True),
66-
sa.Column('protocol_id', sa.VARCHAR(), nullable=True),
67-
sa.Column('create_time', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=True),
68-
sa.Column('update_time', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=True),
69-
sa.Column('reorg', sa.BOOLEAN(), nullable=True),
70-
sa.PrimaryKeyConstraint('vault_address', 'wallet_address', 'block_timestamp', 'block_number')
93+
op.create_index(
94+
"af_staked_fbtc_detail_hist_wallet_block_desc_index",
95+
"af_staked_fbtc_detail_hist",
96+
[sa.text("wallet_address DESC"), sa.text("block_timestamp DESC")],
97+
unique=False,
7198
)
72-
op.create_index('af_staked_fbtc_detail_hist_protocol_block_desc_index', 'af_staked_fbtc_detail_hist', [sa.text('protocol_id DESC'), sa.text('block_timestamp DESC')], unique=False)
73-
op.create_index('af_staked_fbtc_detail_hist_wallet_block_desc_index', 'af_staked_fbtc_detail_hist', [sa.text('wallet_address DESC'), sa.text('block_timestamp DESC')], unique=False)
7499
# ### end Alembic commands ###
75100

76101

77102
def downgrade() -> None:
78103
# ### commands auto generated by Alembic - please adjust! ###
79-
op.drop_index('af_staked_fbtc_detail_hist_wallet_block_desc_index', table_name='af_staked_fbtc_detail_hist')
80-
op.drop_index('af_staked_fbtc_detail_hist_protocol_block_desc_index', table_name='af_staked_fbtc_detail_hist')
81-
op.drop_table('af_staked_fbtc_detail_hist')
82-
op.drop_index('af_staked_fbtc_current_wallet_block_desc_index', table_name='af_staked_fbtc_current')
83-
op.drop_index('af_staked_fbtc_current_protocol_block_desc_index', table_name='af_staked_fbtc_current')
84-
op.drop_table('af_staked_fbtc_current')
85-
op.drop_table('af_merchant_moe_pool_data_hist')
86-
op.drop_table('af_merchant_moe_pool_data_current')
104+
op.drop_index("af_staked_fbtc_detail_hist_wallet_block_desc_index", table_name="af_staked_fbtc_detail_hist")
105+
op.drop_index("af_staked_fbtc_detail_hist_protocol_block_desc_index", table_name="af_staked_fbtc_detail_hist")
106+
op.drop_table("af_staked_fbtc_detail_hist")
107+
op.drop_index("af_staked_fbtc_current_wallet_block_desc_index", table_name="af_staked_fbtc_current")
108+
op.drop_index("af_staked_fbtc_current_protocol_block_desc_index", table_name="af_staked_fbtc_current")
109+
op.drop_table("af_staked_fbtc_current")
110+
op.drop_table("af_merchant_moe_pool_data_hist")
111+
op.drop_table("af_merchant_moe_pool_data_current")
87112
# ### end Alembic commands ###

0 commit comments

Comments
 (0)