Skip to content

Commit

Permalink
Merge pull request #1074 from moonstream-to/mdb-v3-ext-chains
Browse files Browse the repository at this point in the history
Game7 Orbit, Arbitrum, Xai and Mantle blockchain mdb v3 models
  • Loading branch information
kompotkot authored Jun 3, 2024
2 parents a1e3bb4 + 34aba69 commit 565e242
Show file tree
Hide file tree
Showing 7 changed files with 1,246 additions and 1 deletion.
7 changes: 7 additions & 0 deletions moonstreamdb-v3/moonstreamdbv3/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
ArbitrumNovaLabel,
ArbitrumOneLabel,
ArbitrumSepoliaLabel,
Game7OrbitArbitrumSepoliaLabel,
XaiLabel,
XaiSepoliaLabel,
AvalancheLabel,
Expand All @@ -48,6 +49,8 @@
ProofOfPlayApexLabel,
StarknetLabel,
StarknetSepoliaLabel,
MantleLabel,
MantleSepoliaLabel,
)


Expand All @@ -63,7 +66,9 @@ def include_symbol(tablename, schema):
ZkSyncEraSepoliaLabel.__tablename__,
BaseLabel.__tablename__,
ArbitrumNovaLabel.__tablename__,
ArbitrumOneLabel.__tablename__,
ArbitrumSepoliaLabel.__tablename__,
Game7OrbitArbitrumSepoliaLabel.__tablename__,
XaiLabel.__tablename__,
XaiSepoliaLabel.__tablename__,
AvalancheLabel.__tablename__,
Expand All @@ -73,6 +78,8 @@ def include_symbol(tablename, schema):
ProofOfPlayApexLabel.__tablename__,
StarknetLabel.__tablename__,
StarknetSepoliaLabel.__tablename__,
MantleLabel.__tablename__,
MantleSepoliaLabel.__tablename__,
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
"""Game7 Orbit and Mantle blockchain models
Revision ID: 9ca39b11e12a
Revises: d2ceff33be47
Create Date: 2024-05-29 13:17:07.194421
"""
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 = '9ca39b11e12a'
down_revision: Union[str, None] = 'd2ceff33be47'
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('game7_orbit_arbitrum_sepolia_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.VARCHAR(length=64), nullable=True),
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
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_game7_orbit_arbitrum_sepolia_labels')),
sa.UniqueConstraint('id', name=op.f('uq_game7_orbit_arbitrum_sepolia_labels_id'))
)
op.create_index('ix_g7o_arbitrum_sepolia_labels_addr_block_num', 'game7_orbit_arbitrum_sepolia_labels', ['address', 'block_number'], unique=False)
op.create_index('ix_g7o_arbitrum_sepolia_labels_addr_block_ts', 'game7_orbit_arbitrum_sepolia_labels', ['address', 'block_timestamp'], unique=False)
op.create_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_address'), 'game7_orbit_arbitrum_sepolia_labels', ['address'], unique=False)
op.create_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_block_number'), 'game7_orbit_arbitrum_sepolia_labels', ['block_number'], unique=False)
op.create_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_caller_address'), 'game7_orbit_arbitrum_sepolia_labels', ['caller_address'], unique=False)
op.create_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_label'), 'game7_orbit_arbitrum_sepolia_labels', ['label'], unique=False)
op.create_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_label_name'), 'game7_orbit_arbitrum_sepolia_labels', ['label_name'], unique=False)
op.create_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_label_type'), 'game7_orbit_arbitrum_sepolia_labels', ['label_type'], unique=False)
op.create_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_origin_address'), 'game7_orbit_arbitrum_sepolia_labels', ['origin_address'], unique=False)
op.create_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_transaction_hash'), 'game7_orbit_arbitrum_sepolia_labels', ['transaction_hash'], unique=False)
op.create_index('uk_g7o_arbitrum_sepolia_labels_tx_hash_log_idx_evt', 'game7_orbit_arbitrum_sepolia_labels', ['transaction_hash', 'log_index'], unique=True, postgresql_where=sa.text("label='seer' and label_type='event'"))
op.create_index('uk_g7o_arbitrum_sepolia_labels_tx_hash_tx_call', 'game7_orbit_arbitrum_sepolia_labels', ['transaction_hash'], unique=True, postgresql_where=sa.text("label='seer' and label_type='tx_call'"))
op.create_table('mantle_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.VARCHAR(length=64), nullable=True),
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
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_mantle_labels')),
sa.UniqueConstraint('id', name=op.f('uq_mantle_labels_id'))
)
op.create_index('ix_mantle_labels_addr_block_num', 'mantle_labels', ['address', 'block_number'], unique=False)
op.create_index('ix_mantle_labels_addr_block_ts', 'mantle_labels', ['address', 'block_timestamp'], unique=False)
op.create_index(op.f('ix_mantle_labels_address'), 'mantle_labels', ['address'], unique=False)
op.create_index(op.f('ix_mantle_labels_block_number'), 'mantle_labels', ['block_number'], unique=False)
op.create_index(op.f('ix_mantle_labels_caller_address'), 'mantle_labels', ['caller_address'], unique=False)
op.create_index(op.f('ix_mantle_labels_label'), 'mantle_labels', ['label'], unique=False)
op.create_index(op.f('ix_mantle_labels_label_name'), 'mantle_labels', ['label_name'], unique=False)
op.create_index(op.f('ix_mantle_labels_label_type'), 'mantle_labels', ['label_type'], unique=False)
op.create_index(op.f('ix_mantle_labels_origin_address'), 'mantle_labels', ['origin_address'], unique=False)
op.create_index(op.f('ix_mantle_labels_transaction_hash'), 'mantle_labels', ['transaction_hash'], unique=False)
op.create_index('uk_mantle_labels_tx_hash_log_idx_evt', 'mantle_labels', ['transaction_hash', 'log_index'], unique=True, postgresql_where=sa.text("label='seer' and label_type='event'"))
op.create_index('uk_mantle_labels_tx_hash_tx_call', 'mantle_labels', ['transaction_hash'], unique=True, postgresql_where=sa.text("label='seer' and label_type='tx_call'"))
op.create_table('mantle_sepolia_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.VARCHAR(length=64), nullable=True),
sa.Column('origin_address', sa.VARCHAR(length=64), nullable=True),
sa.Column('address', sa.VARCHAR(length=64), nullable=True),
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_mantle_sepolia_labels')),
sa.UniqueConstraint('id', name=op.f('uq_mantle_sepolia_labels_id'))
)
op.create_index('ix_mantle_sepolia_labels_addr_block_num', 'mantle_sepolia_labels', ['address', 'block_number'], unique=False)
op.create_index('ix_mantle_sepolia_labels_addr_block_ts', 'mantle_sepolia_labels', ['address', 'block_timestamp'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_address'), 'mantle_sepolia_labels', ['address'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_block_number'), 'mantle_sepolia_labels', ['block_number'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_caller_address'), 'mantle_sepolia_labels', ['caller_address'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_label'), 'mantle_sepolia_labels', ['label'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_label_name'), 'mantle_sepolia_labels', ['label_name'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_label_type'), 'mantle_sepolia_labels', ['label_type'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_origin_address'), 'mantle_sepolia_labels', ['origin_address'], unique=False)
op.create_index(op.f('ix_mantle_sepolia_labels_transaction_hash'), 'mantle_sepolia_labels', ['transaction_hash'], unique=False)
op.create_index('uk_mantle_sepolia_labels_tx_hash_log_idx_evt', 'mantle_sepolia_labels', ['transaction_hash', 'log_index'], unique=True, postgresql_where=sa.text("label='seer' and label_type='event'"))
op.create_index('uk_mantle_sepolia_labels_tx_hash_tx_call', 'mantle_sepolia_labels', ['transaction_hash'], unique=True, postgresql_where=sa.text("label='seer' and label_type='tx_call'"))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index('uk_mantle_sepolia_labels_tx_hash_tx_call', table_name='mantle_sepolia_labels', postgresql_where=sa.text("label='seer' and label_type='tx_call'"))
op.drop_index('uk_mantle_sepolia_labels_tx_hash_log_idx_evt', table_name='mantle_sepolia_labels', postgresql_where=sa.text("label='seer' and label_type='event'"))
op.drop_index(op.f('ix_mantle_sepolia_labels_transaction_hash'), table_name='mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_labels_origin_address'), table_name='mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_labels_label_type'), table_name='mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_labels_label_name'), table_name='mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_labels_label'), table_name='mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_labels_caller_address'), table_name='mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_labels_block_number'), table_name='mantle_sepolia_labels')
op.drop_index(op.f('ix_mantle_sepolia_labels_address'), table_name='mantle_sepolia_labels')
op.drop_index('ix_mantle_sepolia_labels_addr_block_ts', table_name='mantle_sepolia_labels')
op.drop_index('ix_mantle_sepolia_labels_addr_block_num', table_name='mantle_sepolia_labels')
op.drop_table('mantle_sepolia_labels')
op.drop_index('uk_mantle_labels_tx_hash_tx_call', table_name='mantle_labels', postgresql_where=sa.text("label='seer' and label_type='tx_call'"))
op.drop_index('uk_mantle_labels_tx_hash_log_idx_evt', table_name='mantle_labels', postgresql_where=sa.text("label='seer' and label_type='event'"))
op.drop_index(op.f('ix_mantle_labels_transaction_hash'), table_name='mantle_labels')
op.drop_index(op.f('ix_mantle_labels_origin_address'), table_name='mantle_labels')
op.drop_index(op.f('ix_mantle_labels_label_type'), table_name='mantle_labels')
op.drop_index(op.f('ix_mantle_labels_label_name'), table_name='mantle_labels')
op.drop_index(op.f('ix_mantle_labels_label'), table_name='mantle_labels')
op.drop_index(op.f('ix_mantle_labels_caller_address'), table_name='mantle_labels')
op.drop_index(op.f('ix_mantle_labels_block_number'), table_name='mantle_labels')
op.drop_index(op.f('ix_mantle_labels_address'), table_name='mantle_labels')
op.drop_index('ix_mantle_labels_addr_block_ts', table_name='mantle_labels')
op.drop_index('ix_mantle_labels_addr_block_num', table_name='mantle_labels')
op.drop_table('mantle_labels')
op.drop_index('uk_g7o_arbitrum_sepolia_labels_tx_hash_tx_call', table_name='game7_orbit_arbitrum_sepolia_labels', postgresql_where=sa.text("label='seer' and label_type='tx_call'"))
op.drop_index('uk_g7o_arbitrum_sepolia_labels_tx_hash_log_idx_evt', table_name='game7_orbit_arbitrum_sepolia_labels', postgresql_where=sa.text("label='seer' and label_type='event'"))
op.drop_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_transaction_hash'), table_name='game7_orbit_arbitrum_sepolia_labels')
op.drop_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_origin_address'), table_name='game7_orbit_arbitrum_sepolia_labels')
op.drop_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_label_type'), table_name='game7_orbit_arbitrum_sepolia_labels')
op.drop_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_label_name'), table_name='game7_orbit_arbitrum_sepolia_labels')
op.drop_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_label'), table_name='game7_orbit_arbitrum_sepolia_labels')
op.drop_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_caller_address'), table_name='game7_orbit_arbitrum_sepolia_labels')
op.drop_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_block_number'), table_name='game7_orbit_arbitrum_sepolia_labels')
op.drop_index(op.f('ix_game7_orbit_arbitrum_sepolia_labels_address'), table_name='game7_orbit_arbitrum_sepolia_labels')
op.drop_index('ix_g7o_arbitrum_sepolia_labels_addr_block_ts', table_name='game7_orbit_arbitrum_sepolia_labels')
op.drop_index('ix_g7o_arbitrum_sepolia_labels_addr_block_num', table_name='game7_orbit_arbitrum_sepolia_labels')
op.drop_table('game7_orbit_arbitrum_sepolia_labels')
# ### end Alembic commands ###
56 changes: 56 additions & 0 deletions moonstreamdb-v3/moonstreamdbv3/alembic_indexes/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,34 @@
PolygonTransactionIndex,
PolygonLogIndex,
PolygonReorgs,
XaiBlockIndex,
XaiTransactionIndex,
XaiLogIndex,
XaiReorgs,
XaiSepoliaBlockIndex,
XaiSepoliaTransactionIndex,
XaiSepoliaLogIndex,
XaiSepoliaReorgs,
ArbitrumOneBlockIndex,
ArbitrumOneTransactionIndex,
ArbitrumOneLogIndex,
ArbitrumOneReorgs,
ArbitrumSepoliaBlockIndex,
ArbitrumSepoliaTransactionIndex,
ArbitrumSepoliaLogIndex,
ArbitrumSepoliaReorgs,
Game7OrbitArbitrumSepoliaBlockIndex,
Game7OrbitArbitrumSepoliaTransactionIndex,
Game7OrbitArbitrumSepoliaLogIndex,
Game7OrbitArbitrumSepoliaReorgs,
MantleBlockIndex,
MantleTransactionIndex,
MantleLogIndex,
MantleReorgs,
MantleSepoliaBlockIndex,
MantleSepoliaTransactionIndex,
MantleSepoliaLogIndex,
MantleSepoliaReorgs,
AbiJobs,
)

Expand All @@ -50,6 +78,34 @@ def include_symbol(tablename, schema):
PolygonTransactionIndex.__tablename__,
PolygonLogIndex.__tablename__,
PolygonReorgs.__tablename__,
XaiBlockIndex.__tablename__,
XaiTransactionIndex.__tablename__,
XaiLogIndex.__tablename__,
XaiReorgs.__tablename__,
XaiSepoliaBlockIndex.__tablename__,
XaiSepoliaTransactionIndex.__tablename__,
XaiSepoliaLogIndex.__tablename__,
XaiSepoliaReorgs.__tablename__,
ArbitrumOneBlockIndex.__tablename__,
ArbitrumOneTransactionIndex.__tablename__,
ArbitrumOneLogIndex.__tablename__,
ArbitrumOneReorgs.__tablename__,
ArbitrumSepoliaBlockIndex.__tablename__,
ArbitrumSepoliaTransactionIndex.__tablename__,
ArbitrumSepoliaLogIndex.__tablename__,
ArbitrumSepoliaReorgs.__tablename__,
Game7OrbitArbitrumSepoliaBlockIndex.__tablename__,
Game7OrbitArbitrumSepoliaTransactionIndex.__tablename__,
Game7OrbitArbitrumSepoliaLogIndex.__tablename__,
Game7OrbitArbitrumSepoliaReorgs.__tablename__,
MantleBlockIndex.__tablename__,
MantleTransactionIndex.__tablename__,
MantleLogIndex.__tablename__,
MantleReorgs.__tablename__,
MantleSepoliaBlockIndex.__tablename__,
MantleSepoliaTransactionIndex.__tablename__,
MantleSepoliaLogIndex.__tablename__,
MantleSepoliaReorgs.__tablename__,
AbiJobs.__tablename__,
}

Expand Down
Loading

0 comments on commit 565e242

Please sign in to comment.