-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1137 from moonstream-to/add-ronin-chain
Add ronin chain models.
- Loading branch information
Showing
7 changed files
with
747 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
324 changes: 324 additions & 0 deletions
324
moonstreamdb-v3/moonstreamdbv3/alembic/versions/e6d3c285e7cc_add_ronin_chain.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,324 @@ | ||
"""add ronin chain | ||
Revision ID: e6d3c285e7cc | ||
Revises: d816689b786a | ||
Create Date: 2024-11-12 12:54:33.415972 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "e6d3c285e7cc" | ||
down_revision: Union[str, None] = "d816689b786a" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"ronin_labels", | ||
sa.Column("id", sa.UUID(), nullable=False), | ||
sa.Column("label", sa.VARCHAR(length=256), nullable=False), | ||
sa.Column("transaction_hash", sa.VARCHAR(length=128), nullable=False), | ||
sa.Column("log_index", sa.Integer(), nullable=True), | ||
sa.Column("block_number", sa.BigInteger(), nullable=False), | ||
sa.Column("block_hash", sa.VARCHAR(length=256), nullable=False), | ||
sa.Column("block_timestamp", sa.BigInteger(), nullable=False), | ||
sa.Column("caller_address", sa.LargeBinary(), nullable=True), | ||
sa.Column("origin_address", sa.LargeBinary(), nullable=True), | ||
sa.Column("address", sa.LargeBinary(), nullable=False), | ||
sa.Column("label_name", sa.Text(), nullable=True), | ||
sa.Column("label_type", sa.VARCHAR(length=64), nullable=True), | ||
sa.Column("label_data", postgresql.JSONB(astext_type=sa.Text()), nullable=True), | ||
sa.Column( | ||
"created_at", | ||
sa.DateTime(timezone=True), | ||
server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), | ||
nullable=False, | ||
), | ||
sa.PrimaryKeyConstraint("id", name=op.f("pk_ronin_labels")), | ||
sa.UniqueConstraint("id", name=op.f("uq_ronin_labels_id")), | ||
) | ||
op.create_index( | ||
"ix_ronin_labels_addr_block_num", | ||
"ronin_labels", | ||
["address", "block_number"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
"ix_ronin_labels_addr_block_ts", | ||
"ronin_labels", | ||
["address", "block_timestamp"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_labels_address"), "ronin_labels", ["address"], unique=False | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_labels_block_number"), | ||
"ronin_labels", | ||
["block_number"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_labels_caller_address"), | ||
"ronin_labels", | ||
["caller_address"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_labels_label"), "ronin_labels", ["label"], unique=False | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_labels_label_name"), "ronin_labels", ["label_name"], unique=False | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_labels_label_type"), "ronin_labels", ["label_type"], unique=False | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_labels_origin_address"), | ||
"ronin_labels", | ||
["origin_address"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_labels_transaction_hash"), | ||
"ronin_labels", | ||
["transaction_hash"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
"uk_ronin_labels_tx_hash_log_idx_evt", | ||
"ronin_labels", | ||
["transaction_hash", "log_index"], | ||
unique=True, | ||
postgresql_where=sa.text("label='seer' and label_type='event'"), | ||
) | ||
op.create_index( | ||
"uk_ronin_labels_tx_hash_log_idx_evt_raw", | ||
"ronin_labels", | ||
["transaction_hash", "log_index"], | ||
unique=True, | ||
postgresql_where=sa.text("label='seer-raw' and label_type='event'"), | ||
) | ||
op.create_index( | ||
"uk_ronin_labels_tx_hash_tx_call", | ||
"ronin_labels", | ||
["transaction_hash"], | ||
unique=True, | ||
postgresql_where=sa.text("label='seer' and label_type='tx_call'"), | ||
) | ||
op.create_index( | ||
"uk_ronin_labels_tx_hash_tx_call_raw", | ||
"ronin_labels", | ||
["transaction_hash"], | ||
unique=True, | ||
postgresql_where=sa.text("label='seer-raw' and label_type='tx_call'"), | ||
) | ||
op.create_table( | ||
"ronin_saigon_labels", | ||
sa.Column("id", sa.UUID(), nullable=False), | ||
sa.Column("label", sa.VARCHAR(length=256), nullable=False), | ||
sa.Column("transaction_hash", sa.VARCHAR(length=128), nullable=False), | ||
sa.Column("log_index", sa.Integer(), nullable=True), | ||
sa.Column("block_number", sa.BigInteger(), nullable=False), | ||
sa.Column("block_hash", sa.VARCHAR(length=256), nullable=False), | ||
sa.Column("block_timestamp", sa.BigInteger(), nullable=False), | ||
sa.Column("caller_address", sa.LargeBinary(), nullable=True), | ||
sa.Column("origin_address", sa.LargeBinary(), nullable=True), | ||
sa.Column("address", sa.LargeBinary(), nullable=False), | ||
sa.Column("label_name", sa.Text(), nullable=True), | ||
sa.Column("label_type", sa.VARCHAR(length=64), nullable=True), | ||
sa.Column("label_data", postgresql.JSONB(astext_type=sa.Text()), nullable=True), | ||
sa.Column( | ||
"created_at", | ||
sa.DateTime(timezone=True), | ||
server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), | ||
nullable=False, | ||
), | ||
sa.PrimaryKeyConstraint("id", name=op.f("pk_ronin_saigon_labels")), | ||
sa.UniqueConstraint("id", name=op.f("uq_ronin_saigon_labels_id")), | ||
) | ||
op.create_index( | ||
"ix_ronin_saigon_labels_addr_block_num", | ||
"ronin_saigon_labels", | ||
["address", "block_number"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
"ix_ronin_saigon_labels_addr_block_ts", | ||
"ronin_saigon_labels", | ||
["address", "block_timestamp"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_saigon_labels_address"), | ||
"ronin_saigon_labels", | ||
["address"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_saigon_labels_block_number"), | ||
"ronin_saigon_labels", | ||
["block_number"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_saigon_labels_caller_address"), | ||
"ronin_saigon_labels", | ||
["caller_address"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_saigon_labels_label"), | ||
"ronin_saigon_labels", | ||
["label"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_saigon_labels_label_name"), | ||
"ronin_saigon_labels", | ||
["label_name"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_saigon_labels_label_type"), | ||
"ronin_saigon_labels", | ||
["label_type"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_saigon_labels_origin_address"), | ||
"ronin_saigon_labels", | ||
["origin_address"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
op.f("ix_ronin_saigon_labels_transaction_hash"), | ||
"ronin_saigon_labels", | ||
["transaction_hash"], | ||
unique=False, | ||
) | ||
op.create_index( | ||
"uk_ronin_saigon_labels_tx_hash_log_idx_evt", | ||
"ronin_saigon_labels", | ||
["transaction_hash", "log_index"], | ||
unique=True, | ||
postgresql_where=sa.text("label='seer' and label_type='event'"), | ||
) | ||
op.create_index( | ||
"uk_ronin_saigon_labels_tx_hash_log_idx_evt_raw", | ||
"ronin_saigon_labels", | ||
["transaction_hash", "log_index"], | ||
unique=True, | ||
postgresql_where=sa.text("label='seer-raw' and label_type='event'"), | ||
) | ||
op.create_index( | ||
"uk_ronin_saigon_labels_tx_hash_tx_call", | ||
"ronin_saigon_labels", | ||
["transaction_hash"], | ||
unique=True, | ||
postgresql_where=sa.text("label='seer' and label_type='tx_call'"), | ||
) | ||
op.create_index( | ||
"uk_ronin_saigon_labels_tx_hash_tx_call_raw", | ||
"ronin_saigon_labels", | ||
["transaction_hash"], | ||
unique=True, | ||
postgresql_where=sa.text("label='seer-raw' and label_type='tx_call'"), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index( | ||
"uk_ronin_saigon_labels_tx_hash_tx_call_raw", | ||
table_name="ronin_saigon_labels", | ||
postgresql_where=sa.text("label='seer-raw' and label_type='tx_call'"), | ||
) | ||
op.drop_index( | ||
"uk_ronin_saigon_labels_tx_hash_tx_call", | ||
table_name="ronin_saigon_labels", | ||
postgresql_where=sa.text("label='seer' and label_type='tx_call'"), | ||
) | ||
op.drop_index( | ||
"uk_ronin_saigon_labels_tx_hash_log_idx_evt_raw", | ||
table_name="ronin_saigon_labels", | ||
postgresql_where=sa.text("label='seer-raw' and label_type='event'"), | ||
) | ||
op.drop_index( | ||
"uk_ronin_saigon_labels_tx_hash_log_idx_evt", | ||
table_name="ronin_saigon_labels", | ||
postgresql_where=sa.text("label='seer' and label_type='event'"), | ||
) | ||
op.drop_index( | ||
op.f("ix_ronin_saigon_labels_transaction_hash"), | ||
table_name="ronin_saigon_labels", | ||
) | ||
op.drop_index( | ||
op.f("ix_ronin_saigon_labels_origin_address"), table_name="ronin_saigon_labels" | ||
) | ||
op.drop_index( | ||
op.f("ix_ronin_saigon_labels_label_type"), table_name="ronin_saigon_labels" | ||
) | ||
op.drop_index( | ||
op.f("ix_ronin_saigon_labels_label_name"), table_name="ronin_saigon_labels" | ||
) | ||
op.drop_index( | ||
op.f("ix_ronin_saigon_labels_label"), table_name="ronin_saigon_labels" | ||
) | ||
op.drop_index( | ||
op.f("ix_ronin_saigon_labels_caller_address"), table_name="ronin_saigon_labels" | ||
) | ||
op.drop_index( | ||
op.f("ix_ronin_saigon_labels_block_number"), table_name="ronin_saigon_labels" | ||
) | ||
op.drop_index( | ||
op.f("ix_ronin_saigon_labels_address"), table_name="ronin_saigon_labels" | ||
) | ||
op.drop_index( | ||
"ix_ronin_saigon_labels_addr_block_ts", table_name="ronin_saigon_labels" | ||
) | ||
op.drop_index( | ||
"ix_ronin_saigon_labels_addr_block_num", table_name="ronin_saigon_labels" | ||
) | ||
op.drop_table("ronin_saigon_labels") | ||
op.drop_index( | ||
"uk_ronin_labels_tx_hash_tx_call_raw", | ||
table_name="ronin_labels", | ||
postgresql_where=sa.text("label='seer-raw' and label_type='tx_call'"), | ||
) | ||
op.drop_index( | ||
"uk_ronin_labels_tx_hash_tx_call", | ||
table_name="ronin_labels", | ||
postgresql_where=sa.text("label='seer' and label_type='tx_call'"), | ||
) | ||
op.drop_index( | ||
"uk_ronin_labels_tx_hash_log_idx_evt_raw", | ||
table_name="ronin_labels", | ||
postgresql_where=sa.text("label='seer-raw' and label_type='event'"), | ||
) | ||
op.drop_index( | ||
"uk_ronin_labels_tx_hash_log_idx_evt", | ||
table_name="ronin_labels", | ||
postgresql_where=sa.text("label='seer' and label_type='event'"), | ||
) | ||
op.drop_index(op.f("ix_ronin_labels_transaction_hash"), table_name="ronin_labels") | ||
op.drop_index(op.f("ix_ronin_labels_origin_address"), table_name="ronin_labels") | ||
op.drop_index(op.f("ix_ronin_labels_label_type"), table_name="ronin_labels") | ||
op.drop_index(op.f("ix_ronin_labels_label_name"), table_name="ronin_labels") | ||
op.drop_index(op.f("ix_ronin_labels_label"), table_name="ronin_labels") | ||
op.drop_index(op.f("ix_ronin_labels_caller_address"), table_name="ronin_labels") | ||
op.drop_index(op.f("ix_ronin_labels_block_number"), table_name="ronin_labels") | ||
op.drop_index(op.f("ix_ronin_labels_address"), table_name="ronin_labels") | ||
op.drop_index("ix_ronin_labels_addr_block_ts", table_name="ronin_labels") | ||
op.drop_index("ix_ronin_labels_addr_block_num", table_name="ronin_labels") | ||
op.drop_table("ronin_labels") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.