Skip to content

Commit b435b82

Browse files
authored
add merchant moe table scripts (HemeraProtocol#172)
1 parent 1ef6fd0 commit b435b82

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
"""add merchant moe table
2+
3+
Revision ID: 67015d9fa59b
4+
Revises: c609922eae7a
5+
Create Date: 2024-09-27 17:00:46.320469
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
from sqlalchemy.dialects import postgresql
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = '67015d9fa59b'
16+
down_revision: Union[str, None] = 'c609922eae7a'
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
# ### 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')
33+
)
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')
44+
)
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')
56+
)
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')
71+
)
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)
74+
# ### end Alembic commands ###
75+
76+
77+
def downgrade() -> None:
78+
# ### 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')
87+
# ### end Alembic commands ###

0 commit comments

Comments
 (0)