Skip to content

Commit 6b518fb

Browse files
author
Andrey
committed
Update migration.
1 parent 1f8f7f9 commit 6b518fb

File tree

1 file changed

+91
-6
lines changed

1 file changed

+91
-6
lines changed

moonstreamdb-v3/moonstreamdbv3/alembic/versions/d13b6bb1d214_add_transactions.py renamed to moonstreamdb-v3/moonstreamdbv3/alembic/versions/a6580c96ae2c_add_raw_transactions.py

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
"""add transactions
1+
"""add raw transactions
22
3-
Revision ID: d13b6bb1d214
4-
Revises: d816689b786a
5-
Create Date: 2024-11-10 23:34:21.581396
3+
Revision ID: a6580c96ae2c
4+
Revises: e6d3c285e7cc
5+
Create Date: 2024-11-13 11:56:48.605875
66
77
"""
88

@@ -13,8 +13,8 @@
1313
from sqlalchemy.dialects import postgresql
1414

1515
# revision identifiers, used by Alembic.
16-
revision: str = "d13b6bb1d214"
17-
down_revision: Union[str, None] = "d816689b786a"
16+
revision: str = "a6580c96ae2c"
17+
down_revision: Union[str, None] = "e6d3c285e7cc"
1818
branch_labels: Union[str, Sequence[str], None] = None
1919
depends_on: Union[str, Sequence[str], None] = None
2020

@@ -1569,6 +1569,72 @@ def upgrade() -> None:
15691569
["value"],
15701570
unique=False,
15711571
)
1572+
op.create_table(
1573+
"ronin_transactions",
1574+
sa.Column("hash", sa.VARCHAR(length=256), nullable=False),
1575+
sa.Column("block_timestamp", sa.BigInteger(), nullable=False),
1576+
sa.Column("block_hash", sa.VARCHAR(length=256), nullable=False),
1577+
sa.Column("from_address", sa.LargeBinary(), nullable=True),
1578+
sa.Column("to_address", sa.LargeBinary(), nullable=True),
1579+
sa.Column("gas", sa.BigInteger(), nullable=True),
1580+
sa.Column("gas_price", sa.BigInteger(), nullable=True),
1581+
sa.Column("max_fee_per_gas", sa.BigInteger(), nullable=True),
1582+
sa.Column("max_priority_fee_per_gas", sa.BigInteger(), nullable=True),
1583+
sa.Column("input", sa.Text(), nullable=True),
1584+
sa.Column("nonce", sa.BigInteger(), nullable=True),
1585+
sa.Column("transaction_index", sa.BigInteger(), nullable=True),
1586+
sa.Column("transaction_type", sa.Integer(), nullable=True),
1587+
sa.Column("value", sa.BigInteger(), nullable=True),
1588+
sa.Column(
1589+
"indexed_at",
1590+
sa.DateTime(timezone=True),
1591+
server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
1592+
nullable=False,
1593+
),
1594+
sa.PrimaryKeyConstraint("hash", name=op.f("pk_ronin_transactions")),
1595+
)
1596+
op.create_index(
1597+
op.f("ix_ronin_transactions_block_hash"),
1598+
"ronin_transactions",
1599+
["block_hash"],
1600+
unique=False,
1601+
)
1602+
op.create_index(
1603+
op.f("ix_ronin_transactions_block_timestamp"),
1604+
"ronin_transactions",
1605+
["block_timestamp"],
1606+
unique=False,
1607+
)
1608+
op.create_index(
1609+
op.f("ix_ronin_transactions_from_address"),
1610+
"ronin_transactions",
1611+
["from_address"],
1612+
unique=False,
1613+
)
1614+
op.create_index(
1615+
op.f("ix_ronin_transactions_gas"), "ronin_transactions", ["gas"], unique=False
1616+
)
1617+
op.create_index(
1618+
op.f("ix_ronin_transactions_gas_price"),
1619+
"ronin_transactions",
1620+
["gas_price"],
1621+
unique=False,
1622+
)
1623+
op.create_index(
1624+
op.f("ix_ronin_transactions_hash"), "ronin_transactions", ["hash"], unique=True
1625+
)
1626+
op.create_index(
1627+
op.f("ix_ronin_transactions_to_address"),
1628+
"ronin_transactions",
1629+
["to_address"],
1630+
unique=False,
1631+
)
1632+
op.create_index(
1633+
op.f("ix_ronin_transactions_value"),
1634+
"ronin_transactions",
1635+
["value"],
1636+
unique=False,
1637+
)
15721638
op.create_table(
15731639
"sepolia_transactions",
15741640
sa.Column("hash", sa.VARCHAR(length=256), nullable=False),
@@ -2142,6 +2208,25 @@ def downgrade() -> None:
21422208
op.f("ix_sepolia_transactions_block_hash"), table_name="sepolia_transactions"
21432209
)
21442210
op.drop_table("sepolia_transactions")
2211+
op.drop_index(op.f("ix_ronin_transactions_value"), table_name="ronin_transactions")
2212+
op.drop_index(
2213+
op.f("ix_ronin_transactions_to_address"), table_name="ronin_transactions"
2214+
)
2215+
op.drop_index(op.f("ix_ronin_transactions_hash"), table_name="ronin_transactions")
2216+
op.drop_index(
2217+
op.f("ix_ronin_transactions_gas_price"), table_name="ronin_transactions"
2218+
)
2219+
op.drop_index(op.f("ix_ronin_transactions_gas"), table_name="ronin_transactions")
2220+
op.drop_index(
2221+
op.f("ix_ronin_transactions_from_address"), table_name="ronin_transactions"
2222+
)
2223+
op.drop_index(
2224+
op.f("ix_ronin_transactions_block_timestamp"), table_name="ronin_transactions"
2225+
)
2226+
op.drop_index(
2227+
op.f("ix_ronin_transactions_block_hash"), table_name="ronin_transactions"
2228+
)
2229+
op.drop_table("ronin_transactions")
21452230
op.drop_index(
21462231
op.f("ix_proofofplay_apex_transactions_value"),
21472232
table_name="proofofplay_apex_transactions",

0 commit comments

Comments
 (0)