|
5 | 5 | Create Date: 2024-09-27 17:00:46.320469
|
6 | 6 |
|
7 | 7 | """
|
| 8 | + |
8 | 9 | from typing import Sequence, Union
|
9 | 10 |
|
10 |
| -from alembic import op |
11 | 11 | import sqlalchemy as sa
|
| 12 | +from alembic import op |
12 | 13 | from sqlalchemy.dialects import postgresql
|
13 | 14 |
|
14 | 15 | # 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" |
17 | 18 | branch_labels: Union[str, Sequence[str], None] = None
|
18 | 19 | depends_on: Union[str, Sequence[str], None] = None
|
19 | 20 |
|
20 | 21 |
|
21 | 22 | def upgrade() -> None:
|
22 | 23 | # ### 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, |
33 | 72 | )
|
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"), |
44 | 86 | )
|
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, |
56 | 92 | )
|
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, |
71 | 98 | )
|
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 | 99 | # ### end Alembic commands ###
|
75 | 100 |
|
76 | 101 |
|
77 | 102 | def downgrade() -> None:
|
78 | 103 | # ### 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") |
87 | 112 | # ### end Alembic commands ###
|
0 commit comments