diff --git a/moonstreamdb/alembic/env.py b/moonstreamdb/alembic/env.py index 2d4c8c37..cce72799 100644 --- a/moonstreamdb/alembic/env.py +++ b/moonstreamdb/alembic/env.py @@ -79,6 +79,9 @@ from moonstreamdb.models import ( BlastSepoliaBlock, BlastSepoliaLabel, BlastSepoliaTransaction, + ProofOfPlayApexBlock, + ProofOfPlayApexLabel, + ProofOfPlayApexTransaction, ) @@ -138,6 +141,9 @@ def include_symbol(tablename, schema): BlastSepoliaBlock.__tablename__, BlastSepoliaLabel.__tablename__, BlastSepoliaTransaction.__tablename__, + ProofOfPlayApexBlock.__tablename__, + ProofOfPlayApexLabel.__tablename__, + ProofOfPlayApexTransaction.__tablename__, } diff --git a/moonstreamdb/alembic/versions/a95cbab56a0b_avalanche_and_zksync_era_sepolia_.py b/moonstreamdb/alembic/versions/a95cbab56a0b_avalanche_and_zksync_era_sepolia_.py index 961c35c9..68c16edb 100644 --- a/moonstreamdb/alembic/versions/a95cbab56a0b_avalanche_and_zksync_era_sepolia_.py +++ b/moonstreamdb/alembic/versions/a95cbab56a0b_avalanche_and_zksync_era_sepolia_.py @@ -5,327 +5,836 @@ Revises: a99b97acc39e Create Date: 2024-03-28 11:08:06.677075 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision = 'a95cbab56a0b' -down_revision = 'a99b97acc39e' +revision = "a95cbab56a0b" +down_revision = "a99b97acc39e" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.create_table('avalanche_blocks', - sa.Column('block_number', sa.BigInteger(), nullable=False), - sa.Column('difficulty', sa.BigInteger(), nullable=True), - sa.Column('extra_data', sa.VARCHAR(length=128), nullable=True), - sa.Column('gas_limit', sa.BigInteger(), nullable=True), - sa.Column('gas_used', sa.BigInteger(), nullable=True), - sa.Column('base_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('logs_bloom', sa.VARCHAR(length=1024), nullable=True), - sa.Column('miner', sa.VARCHAR(length=256), nullable=True), - sa.Column('nonce', sa.VARCHAR(length=256), nullable=True), - sa.Column('parent_hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('receipt_root', sa.VARCHAR(length=256), nullable=True), - sa.Column('uncles', sa.VARCHAR(length=256), nullable=True), - sa.Column('size', sa.Integer(), nullable=True), - sa.Column('state_root', sa.VARCHAR(length=256), nullable=True), - sa.Column('timestamp', sa.BigInteger(), nullable=True), - sa.Column('total_difficulty', sa.VARCHAR(length=256), nullable=True), - sa.Column('transactions_root', sa.VARCHAR(length=256), nullable=True), - sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), - sa.Column('mix_hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('block_extra_data', sa.VARCHAR(length=256), nullable=True), - sa.Column('block_gas_cost', sa.VARCHAR(length=256), nullable=True), - sa.Column('ext_data_gas_used', sa.VARCHAR(length=256), nullable=True), - sa.Column('ext_data_hash', sa.VARCHAR(length=256), nullable=True), - sa.PrimaryKeyConstraint('block_number', name=op.f('pk_avalanche_blocks')) + op.create_table( + "avalanche_blocks", + sa.Column("block_number", sa.BigInteger(), nullable=False), + sa.Column("difficulty", sa.BigInteger(), nullable=True), + sa.Column("extra_data", sa.VARCHAR(length=128), nullable=True), + sa.Column("gas_limit", sa.BigInteger(), nullable=True), + sa.Column("gas_used", sa.BigInteger(), nullable=True), + sa.Column("base_fee_per_gas", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column("hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("logs_bloom", sa.VARCHAR(length=1024), nullable=True), + sa.Column("miner", sa.VARCHAR(length=256), nullable=True), + sa.Column("nonce", sa.VARCHAR(length=256), nullable=True), + sa.Column("parent_hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("receipt_root", sa.VARCHAR(length=256), nullable=True), + sa.Column("uncles", sa.VARCHAR(length=256), nullable=True), + sa.Column("size", sa.Integer(), nullable=True), + sa.Column("state_root", sa.VARCHAR(length=256), nullable=True), + sa.Column("timestamp", sa.BigInteger(), nullable=True), + sa.Column("total_difficulty", sa.VARCHAR(length=256), nullable=True), + sa.Column("transactions_root", sa.VARCHAR(length=256), nullable=True), + sa.Column( + "indexed_at", + sa.DateTime(timezone=True), + server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), + nullable=False, + ), + sa.Column("mix_hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("block_extra_data", sa.VARCHAR(length=256), nullable=True), + sa.Column("block_gas_cost", sa.VARCHAR(length=256), nullable=True), + sa.Column("ext_data_gas_used", sa.VARCHAR(length=256), nullable=True), + sa.Column("ext_data_hash", sa.VARCHAR(length=256), nullable=True), + sa.PrimaryKeyConstraint("block_number", name=op.f("pk_avalanche_blocks")), ) - op.create_index(op.f('ix_avalanche_blocks_block_number'), 'avalanche_blocks', ['block_number'], unique=True) - op.create_index(op.f('ix_avalanche_blocks_hash'), 'avalanche_blocks', ['hash'], unique=False) - op.create_index(op.f('ix_avalanche_blocks_timestamp'), 'avalanche_blocks', ['timestamp'], unique=False) - op.create_table('avalanche_fuji_blocks', - sa.Column('block_number', sa.BigInteger(), nullable=False), - sa.Column('difficulty', sa.BigInteger(), nullable=True), - sa.Column('extra_data', sa.VARCHAR(length=128), nullable=True), - sa.Column('gas_limit', sa.BigInteger(), nullable=True), - sa.Column('gas_used', sa.BigInteger(), nullable=True), - sa.Column('base_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('logs_bloom', sa.VARCHAR(length=1024), nullable=True), - sa.Column('miner', sa.VARCHAR(length=256), nullable=True), - sa.Column('nonce', sa.VARCHAR(length=256), nullable=True), - sa.Column('parent_hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('receipt_root', sa.VARCHAR(length=256), nullable=True), - sa.Column('uncles', sa.VARCHAR(length=256), nullable=True), - sa.Column('size', sa.Integer(), nullable=True), - sa.Column('state_root', sa.VARCHAR(length=256), nullable=True), - sa.Column('timestamp', sa.BigInteger(), nullable=True), - sa.Column('total_difficulty', sa.VARCHAR(length=256), nullable=True), - sa.Column('transactions_root', sa.VARCHAR(length=256), nullable=True), - sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), - sa.Column('mix_hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('block_extra_data', sa.VARCHAR(length=256), nullable=True), - sa.Column('block_gas_cost', sa.VARCHAR(length=256), nullable=True), - sa.Column('ext_data_gas_used', sa.VARCHAR(length=256), nullable=True), - sa.Column('ext_data_hash', sa.VARCHAR(length=256), nullable=True), - sa.PrimaryKeyConstraint('block_number', name=op.f('pk_avalanche_fuji_blocks')) + op.create_index( + op.f("ix_avalanche_blocks_block_number"), + "avalanche_blocks", + ["block_number"], + unique=True, ) - op.create_index(op.f('ix_avalanche_fuji_blocks_block_number'), 'avalanche_fuji_blocks', ['block_number'], unique=True) - op.create_index(op.f('ix_avalanche_fuji_blocks_hash'), 'avalanche_fuji_blocks', ['hash'], unique=False) - op.create_index(op.f('ix_avalanche_fuji_blocks_timestamp'), 'avalanche_fuji_blocks', ['timestamp'], unique=False) - op.create_table('avalanche_fuji_labels', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('label', sa.VARCHAR(length=256), nullable=False), - sa.Column('block_number', sa.BigInteger(), nullable=True), - sa.Column('address', sa.VARCHAR(length=256), nullable=True), - sa.Column('transaction_hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True), - sa.Column('block_timestamp', sa.BigInteger(), nullable=True), - sa.Column('log_index', sa.Integer(), 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_avalanche_fuji_labels')), - sa.UniqueConstraint('id', name=op.f('uq_avalanche_fuji_labels_id')) + op.create_index( + op.f("ix_avalanche_blocks_hash"), "avalanche_blocks", ["hash"], unique=False ) - op.create_index(op.f('ix_avalanche_fuji_labels_address'), 'avalanche_fuji_labels', ['address'], unique=False) - op.create_index('ix_avalanche_fuji_labels_address_block_number', 'avalanche_fuji_labels', ['address', 'block_number'], unique=False) - op.create_index('ix_avalanche_fuji_labels_address_block_timestamp', 'avalanche_fuji_labels', ['address', 'block_timestamp'], unique=False) - op.create_index(op.f('ix_avalanche_fuji_labels_block_number'), 'avalanche_fuji_labels', ['block_number'], unique=False) - op.create_index(op.f('ix_avalanche_fuji_labels_block_timestamp'), 'avalanche_fuji_labels', ['block_timestamp'], unique=False) - op.create_index(op.f('ix_avalanche_fuji_labels_label'), 'avalanche_fuji_labels', ['label'], unique=False) - op.create_index(op.f('ix_avalanche_fuji_labels_transaction_hash'), 'avalanche_fuji_labels', ['transaction_hash'], unique=False) - op.create_table('avalanche_labels', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('label', sa.VARCHAR(length=256), nullable=False), - sa.Column('block_number', sa.BigInteger(), nullable=True), - sa.Column('address', sa.VARCHAR(length=256), nullable=True), - sa.Column('transaction_hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True), - sa.Column('block_timestamp', sa.BigInteger(), nullable=True), - sa.Column('log_index', sa.Integer(), 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_avalanche_labels')), - sa.UniqueConstraint('id', name=op.f('uq_avalanche_labels_id')) + op.create_index( + op.f("ix_avalanche_blocks_timestamp"), + "avalanche_blocks", + ["timestamp"], + unique=False, ) - op.create_index(op.f('ix_avalanche_labels_address'), 'avalanche_labels', ['address'], unique=False) - op.create_index('ix_avalanche_labels_address_block_number', 'avalanche_labels', ['address', 'block_number'], unique=False) - op.create_index('ix_avalanche_labels_address_block_timestamp', 'avalanche_labels', ['address', 'block_timestamp'], unique=False) - op.create_index(op.f('ix_avalanche_labels_block_number'), 'avalanche_labels', ['block_number'], unique=False) - op.create_index(op.f('ix_avalanche_labels_block_timestamp'), 'avalanche_labels', ['block_timestamp'], unique=False) - op.create_index(op.f('ix_avalanche_labels_label'), 'avalanche_labels', ['label'], unique=False) - op.create_index(op.f('ix_avalanche_labels_transaction_hash'), 'avalanche_labels', ['transaction_hash'], unique=False) - op.create_table('zksync_era_sepolia_blocks', - sa.Column('block_number', sa.BigInteger(), nullable=False), - sa.Column('difficulty', sa.BigInteger(), nullable=True), - sa.Column('extra_data', sa.VARCHAR(length=128), nullable=True), - sa.Column('gas_limit', sa.BigInteger(), nullable=True), - sa.Column('gas_used', sa.BigInteger(), nullable=True), - sa.Column('base_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('logs_bloom', sa.VARCHAR(length=1024), nullable=True), - sa.Column('miner', sa.VARCHAR(length=256), nullable=True), - sa.Column('nonce', sa.VARCHAR(length=256), nullable=True), - sa.Column('parent_hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('receipt_root', sa.VARCHAR(length=256), nullable=True), - sa.Column('uncles', sa.VARCHAR(length=256), nullable=True), - sa.Column('size', sa.Integer(), nullable=True), - sa.Column('state_root', sa.VARCHAR(length=256), nullable=True), - sa.Column('timestamp', sa.BigInteger(), nullable=True), - sa.Column('total_difficulty', sa.VARCHAR(length=256), nullable=True), - sa.Column('transactions_root', sa.VARCHAR(length=256), nullable=True), - sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), - sa.Column('mix_hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('sha3_uncles', sa.VARCHAR(length=256), nullable=True), - sa.Column('l1_batch_number', sa.BigInteger(), nullable=True), - sa.Column('l1_batch_timestamp', sa.BigInteger(), nullable=True), - sa.PrimaryKeyConstraint('block_number', name=op.f('pk_zksync_era_sepolia_blocks')) + op.create_table( + "avalanche_fuji_blocks", + sa.Column("block_number", sa.BigInteger(), nullable=False), + sa.Column("difficulty", sa.BigInteger(), nullable=True), + sa.Column("extra_data", sa.VARCHAR(length=128), nullable=True), + sa.Column("gas_limit", sa.BigInteger(), nullable=True), + sa.Column("gas_used", sa.BigInteger(), nullable=True), + sa.Column("base_fee_per_gas", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column("hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("logs_bloom", sa.VARCHAR(length=1024), nullable=True), + sa.Column("miner", sa.VARCHAR(length=256), nullable=True), + sa.Column("nonce", sa.VARCHAR(length=256), nullable=True), + sa.Column("parent_hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("receipt_root", sa.VARCHAR(length=256), nullable=True), + sa.Column("uncles", sa.VARCHAR(length=256), nullable=True), + sa.Column("size", sa.Integer(), nullable=True), + sa.Column("state_root", sa.VARCHAR(length=256), nullable=True), + sa.Column("timestamp", sa.BigInteger(), nullable=True), + sa.Column("total_difficulty", sa.VARCHAR(length=256), nullable=True), + sa.Column("transactions_root", sa.VARCHAR(length=256), nullable=True), + sa.Column( + "indexed_at", + sa.DateTime(timezone=True), + server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), + nullable=False, + ), + sa.Column("mix_hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("block_extra_data", sa.VARCHAR(length=256), nullable=True), + sa.Column("block_gas_cost", sa.VARCHAR(length=256), nullable=True), + sa.Column("ext_data_gas_used", sa.VARCHAR(length=256), nullable=True), + sa.Column("ext_data_hash", sa.VARCHAR(length=256), nullable=True), + sa.PrimaryKeyConstraint("block_number", name=op.f("pk_avalanche_fuji_blocks")), ) - op.create_index(op.f('ix_zksync_era_sepolia_blocks_block_number'), 'zksync_era_sepolia_blocks', ['block_number'], unique=True) - op.create_index(op.f('ix_zksync_era_sepolia_blocks_hash'), 'zksync_era_sepolia_blocks', ['hash'], unique=False) - op.create_index(op.f('ix_zksync_era_sepolia_blocks_timestamp'), 'zksync_era_sepolia_blocks', ['timestamp'], unique=False) - op.create_table('zksync_era_sepolia_labels', - sa.Column('id', sa.UUID(), nullable=False), - sa.Column('label', sa.VARCHAR(length=256), nullable=False), - sa.Column('block_number', sa.BigInteger(), nullable=True), - sa.Column('address', sa.VARCHAR(length=256), nullable=True), - sa.Column('transaction_hash', sa.VARCHAR(length=256), nullable=True), - sa.Column('label_data', postgresql.JSONB(astext_type=sa.Text()), nullable=True), - sa.Column('block_timestamp', sa.BigInteger(), nullable=True), - sa.Column('log_index', sa.Integer(), 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_zksync_era_sepolia_labels')), - sa.UniqueConstraint('id', name=op.f('uq_zksync_era_sepolia_labels_id')) + op.create_index( + op.f("ix_avalanche_fuji_blocks_block_number"), + "avalanche_fuji_blocks", + ["block_number"], + unique=True, ) - op.create_index(op.f('ix_zksync_era_sepolia_labels_address'), 'zksync_era_sepolia_labels', ['address'], unique=False) - op.create_index('ix_zksync_era_sepolia_labels_address_block_number', 'zksync_era_sepolia_labels', ['address', 'block_number'], unique=False) - op.create_index('ix_zksync_era_sepolia_labels_address_block_timestamp', 'zksync_era_sepolia_labels', ['address', 'block_timestamp'], unique=False) - op.create_index(op.f('ix_zksync_era_sepolia_labels_block_number'), 'zksync_era_sepolia_labels', ['block_number'], unique=False) - op.create_index(op.f('ix_zksync_era_sepolia_labels_block_timestamp'), 'zksync_era_sepolia_labels', ['block_timestamp'], unique=False) - op.create_index(op.f('ix_zksync_era_sepolia_labels_label'), 'zksync_era_sepolia_labels', ['label'], unique=False) - op.create_index(op.f('ix_zksync_era_sepolia_labels_transaction_hash'), 'zksync_era_sepolia_labels', ['transaction_hash'], unique=False) - op.create_table('avalanche_fuji_transactions', - sa.Column('hash', sa.VARCHAR(length=256), nullable=False), - sa.Column('block_number', sa.BigInteger(), nullable=False), - sa.Column('from_address', sa.VARCHAR(length=256), nullable=True), - sa.Column('to_address', sa.VARCHAR(length=256), nullable=True), - sa.Column('gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('gas_price', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('max_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('max_priority_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('input', sa.Text(), nullable=True), - sa.Column('nonce', sa.VARCHAR(length=256), nullable=True), - sa.Column('transaction_index', sa.BigInteger(), nullable=True), - sa.Column('transaction_type', sa.Integer(), nullable=True), - sa.Column('value', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), - sa.ForeignKeyConstraint(['block_number'], ['avalanche_fuji_blocks.block_number'], name=op.f('fk_avalanche_fuji_transactions_block_number_avalanche_fuji_blocks'), ondelete='CASCADE'), - sa.PrimaryKeyConstraint('hash', name=op.f('pk_avalanche_fuji_transactions')) + op.create_index( + op.f("ix_avalanche_fuji_blocks_hash"), + "avalanche_fuji_blocks", + ["hash"], + unique=False, ) - op.create_index(op.f('ix_avalanche_fuji_transactions_block_number'), 'avalanche_fuji_transactions', ['block_number'], unique=False) - op.create_index(op.f('ix_avalanche_fuji_transactions_from_address'), 'avalanche_fuji_transactions', ['from_address'], unique=False) - op.create_index(op.f('ix_avalanche_fuji_transactions_gas'), 'avalanche_fuji_transactions', ['gas'], unique=False) - op.create_index(op.f('ix_avalanche_fuji_transactions_gas_price'), 'avalanche_fuji_transactions', ['gas_price'], unique=False) - op.create_index(op.f('ix_avalanche_fuji_transactions_hash'), 'avalanche_fuji_transactions', ['hash'], unique=True) - op.create_index(op.f('ix_avalanche_fuji_transactions_to_address'), 'avalanche_fuji_transactions', ['to_address'], unique=False) - op.create_index(op.f('ix_avalanche_fuji_transactions_value'), 'avalanche_fuji_transactions', ['value'], unique=False) - op.create_table('avalanche_transactions', - sa.Column('hash', sa.VARCHAR(length=256), nullable=False), - sa.Column('block_number', sa.BigInteger(), nullable=False), - sa.Column('from_address', sa.VARCHAR(length=256), nullable=True), - sa.Column('to_address', sa.VARCHAR(length=256), nullable=True), - sa.Column('gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('gas_price', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('max_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('max_priority_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('input', sa.Text(), nullable=True), - sa.Column('nonce', sa.VARCHAR(length=256), nullable=True), - sa.Column('transaction_index', sa.BigInteger(), nullable=True), - sa.Column('transaction_type', sa.Integer(), nullable=True), - sa.Column('value', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), - sa.ForeignKeyConstraint(['block_number'], ['avalanche_blocks.block_number'], name=op.f('fk_avalanche_transactions_block_number_avalanche_blocks'), ondelete='CASCADE'), - sa.PrimaryKeyConstraint('hash', name=op.f('pk_avalanche_transactions')) + op.create_index( + op.f("ix_avalanche_fuji_blocks_timestamp"), + "avalanche_fuji_blocks", + ["timestamp"], + unique=False, ) - op.create_index(op.f('ix_avalanche_transactions_block_number'), 'avalanche_transactions', ['block_number'], unique=False) - op.create_index(op.f('ix_avalanche_transactions_from_address'), 'avalanche_transactions', ['from_address'], unique=False) - op.create_index(op.f('ix_avalanche_transactions_gas'), 'avalanche_transactions', ['gas'], unique=False) - op.create_index(op.f('ix_avalanche_transactions_gas_price'), 'avalanche_transactions', ['gas_price'], unique=False) - op.create_index(op.f('ix_avalanche_transactions_hash'), 'avalanche_transactions', ['hash'], unique=True) - op.create_index(op.f('ix_avalanche_transactions_to_address'), 'avalanche_transactions', ['to_address'], unique=False) - op.create_index(op.f('ix_avalanche_transactions_value'), 'avalanche_transactions', ['value'], unique=False) - op.create_table('zksync_era_sepolia_transactions', - sa.Column('hash', sa.VARCHAR(length=256), nullable=False), - sa.Column('block_number', sa.BigInteger(), nullable=False), - sa.Column('from_address', sa.VARCHAR(length=256), nullable=True), - sa.Column('to_address', sa.VARCHAR(length=256), nullable=True), - sa.Column('gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('gas_price', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('max_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('max_priority_fee_per_gas', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('input', sa.Text(), nullable=True), - sa.Column('nonce', sa.VARCHAR(length=256), nullable=True), - sa.Column('transaction_index', sa.BigInteger(), nullable=True), - sa.Column('transaction_type', sa.Integer(), nullable=True), - sa.Column('value', sa.Numeric(precision=78, scale=0), nullable=True), - sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False), - sa.Column('l1_batch_number', sa.BigInteger(), nullable=True), - sa.Column('l1_batch_tx_index', sa.BigInteger(), nullable=True), - sa.ForeignKeyConstraint(['block_number'], ['zksync_era_sepolia_blocks.block_number'], name=op.f('fk_zksync_era_sepolia_transactions_block_number_zksync_era_sepolia_blocks'), ondelete='CASCADE'), - sa.PrimaryKeyConstraint('hash', name=op.f('pk_zksync_era_sepolia_transactions')) + op.create_table( + "avalanche_fuji_labels", + sa.Column("id", sa.UUID(), nullable=False), + sa.Column("label", sa.VARCHAR(length=256), nullable=False), + sa.Column("block_number", sa.BigInteger(), nullable=True), + sa.Column("address", sa.VARCHAR(length=256), nullable=True), + sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("label_data", postgresql.JSONB(astext_type=sa.Text()), nullable=True), + sa.Column("block_timestamp", sa.BigInteger(), nullable=True), + sa.Column("log_index", sa.Integer(), 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_avalanche_fuji_labels")), + sa.UniqueConstraint("id", name=op.f("uq_avalanche_fuji_labels_id")), + ) + op.create_index( + op.f("ix_avalanche_fuji_labels_address"), + "avalanche_fuji_labels", + ["address"], + unique=False, + ) + op.create_index( + "ix_avalanche_fuji_labels_address_block_number", + "avalanche_fuji_labels", + ["address", "block_number"], + unique=False, + ) + op.create_index( + "ix_avalanche_fuji_labels_address_block_timestamp", + "avalanche_fuji_labels", + ["address", "block_timestamp"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_fuji_labels_block_number"), + "avalanche_fuji_labels", + ["block_number"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_fuji_labels_block_timestamp"), + "avalanche_fuji_labels", + ["block_timestamp"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_fuji_labels_label"), + "avalanche_fuji_labels", + ["label"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_fuji_labels_transaction_hash"), + "avalanche_fuji_labels", + ["transaction_hash"], + unique=False, + ) + op.create_table( + "avalanche_labels", + sa.Column("id", sa.UUID(), nullable=False), + sa.Column("label", sa.VARCHAR(length=256), nullable=False), + sa.Column("block_number", sa.BigInteger(), nullable=True), + sa.Column("address", sa.VARCHAR(length=256), nullable=True), + sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("label_data", postgresql.JSONB(astext_type=sa.Text()), nullable=True), + sa.Column("block_timestamp", sa.BigInteger(), nullable=True), + sa.Column("log_index", sa.Integer(), 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_avalanche_labels")), + sa.UniqueConstraint("id", name=op.f("uq_avalanche_labels_id")), + ) + op.create_index( + op.f("ix_avalanche_labels_address"), + "avalanche_labels", + ["address"], + unique=False, + ) + op.create_index( + "ix_avalanche_labels_address_block_number", + "avalanche_labels", + ["address", "block_number"], + unique=False, + ) + op.create_index( + "ix_avalanche_labels_address_block_timestamp", + "avalanche_labels", + ["address", "block_timestamp"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_labels_block_number"), + "avalanche_labels", + ["block_number"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_labels_block_timestamp"), + "avalanche_labels", + ["block_timestamp"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_labels_label"), "avalanche_labels", ["label"], unique=False + ) + op.create_index( + op.f("ix_avalanche_labels_transaction_hash"), + "avalanche_labels", + ["transaction_hash"], + unique=False, + ) + op.create_table( + "zksync_era_sepolia_blocks", + sa.Column("block_number", sa.BigInteger(), nullable=False), + sa.Column("difficulty", sa.BigInteger(), nullable=True), + sa.Column("extra_data", sa.VARCHAR(length=128), nullable=True), + sa.Column("gas_limit", sa.BigInteger(), nullable=True), + sa.Column("gas_used", sa.BigInteger(), nullable=True), + sa.Column("base_fee_per_gas", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column("hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("logs_bloom", sa.VARCHAR(length=1024), nullable=True), + sa.Column("miner", sa.VARCHAR(length=256), nullable=True), + sa.Column("nonce", sa.VARCHAR(length=256), nullable=True), + sa.Column("parent_hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("receipt_root", sa.VARCHAR(length=256), nullable=True), + sa.Column("uncles", sa.VARCHAR(length=256), nullable=True), + sa.Column("size", sa.Integer(), nullable=True), + sa.Column("state_root", sa.VARCHAR(length=256), nullable=True), + sa.Column("timestamp", sa.BigInteger(), nullable=True), + sa.Column("total_difficulty", sa.VARCHAR(length=256), nullable=True), + sa.Column("transactions_root", sa.VARCHAR(length=256), nullable=True), + sa.Column( + "indexed_at", + sa.DateTime(timezone=True), + server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), + nullable=False, + ), + sa.Column("mix_hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("sha3_uncles", sa.VARCHAR(length=256), nullable=True), + sa.Column("l1_batch_number", sa.BigInteger(), nullable=True), + sa.Column("l1_batch_timestamp", sa.BigInteger(), nullable=True), + sa.PrimaryKeyConstraint( + "block_number", name=op.f("pk_zksync_era_sepolia_blocks") + ), + ) + op.create_index( + op.f("ix_zksync_era_sepolia_blocks_block_number"), + "zksync_era_sepolia_blocks", + ["block_number"], + unique=True, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_blocks_hash"), + "zksync_era_sepolia_blocks", + ["hash"], + unique=False, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_blocks_timestamp"), + "zksync_era_sepolia_blocks", + ["timestamp"], + unique=False, + ) + op.create_table( + "zksync_era_sepolia_labels", + sa.Column("id", sa.UUID(), nullable=False), + sa.Column("label", sa.VARCHAR(length=256), nullable=False), + sa.Column("block_number", sa.BigInteger(), nullable=True), + sa.Column("address", sa.VARCHAR(length=256), nullable=True), + sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=True), + sa.Column("label_data", postgresql.JSONB(astext_type=sa.Text()), nullable=True), + sa.Column("block_timestamp", sa.BigInteger(), nullable=True), + sa.Column("log_index", sa.Integer(), 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_zksync_era_sepolia_labels")), + sa.UniqueConstraint("id", name=op.f("uq_zksync_era_sepolia_labels_id")), + ) + op.create_index( + op.f("ix_zksync_era_sepolia_labels_address"), + "zksync_era_sepolia_labels", + ["address"], + unique=False, + ) + op.create_index( + "ix_zksync_era_sepolia_labels_address_block_number", + "zksync_era_sepolia_labels", + ["address", "block_number"], + unique=False, + ) + op.create_index( + "ix_zksync_era_sepolia_labels_address_block_timestamp", + "zksync_era_sepolia_labels", + ["address", "block_timestamp"], + unique=False, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_labels_block_number"), + "zksync_era_sepolia_labels", + ["block_number"], + unique=False, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_labels_block_timestamp"), + "zksync_era_sepolia_labels", + ["block_timestamp"], + unique=False, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_labels_label"), + "zksync_era_sepolia_labels", + ["label"], + unique=False, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_labels_transaction_hash"), + "zksync_era_sepolia_labels", + ["transaction_hash"], + unique=False, + ) + op.create_table( + "avalanche_fuji_transactions", + sa.Column("hash", sa.VARCHAR(length=256), nullable=False), + sa.Column("block_number", sa.BigInteger(), nullable=False), + sa.Column("from_address", sa.VARCHAR(length=256), nullable=True), + sa.Column("to_address", sa.VARCHAR(length=256), nullable=True), + sa.Column("gas", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column("gas_price", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column("max_fee_per_gas", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column( + "max_priority_fee_per_gas", sa.Numeric(precision=78, scale=0), nullable=True + ), + sa.Column("input", sa.Text(), nullable=True), + sa.Column("nonce", sa.VARCHAR(length=256), nullable=True), + sa.Column("transaction_index", sa.BigInteger(), nullable=True), + sa.Column("transaction_type", sa.Integer(), nullable=True), + sa.Column("value", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column( + "indexed_at", + sa.DateTime(timezone=True), + server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), + nullable=False, + ), + sa.ForeignKeyConstraint( + ["block_number"], + ["avalanche_fuji_blocks.block_number"], + name=op.f( + "fk_avalanche_fuji_transactions_block_number_avalanche_fuji_blocks" + ), + ondelete="CASCADE", + ), + sa.PrimaryKeyConstraint("hash", name=op.f("pk_avalanche_fuji_transactions")), + ) + op.create_index( + op.f("ix_avalanche_fuji_transactions_block_number"), + "avalanche_fuji_transactions", + ["block_number"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_fuji_transactions_from_address"), + "avalanche_fuji_transactions", + ["from_address"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_fuji_transactions_gas"), + "avalanche_fuji_transactions", + ["gas"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_fuji_transactions_gas_price"), + "avalanche_fuji_transactions", + ["gas_price"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_fuji_transactions_hash"), + "avalanche_fuji_transactions", + ["hash"], + unique=True, + ) + op.create_index( + op.f("ix_avalanche_fuji_transactions_to_address"), + "avalanche_fuji_transactions", + ["to_address"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_fuji_transactions_value"), + "avalanche_fuji_transactions", + ["value"], + unique=False, + ) + op.create_table( + "avalanche_transactions", + sa.Column("hash", sa.VARCHAR(length=256), nullable=False), + sa.Column("block_number", sa.BigInteger(), nullable=False), + sa.Column("from_address", sa.VARCHAR(length=256), nullable=True), + sa.Column("to_address", sa.VARCHAR(length=256), nullable=True), + sa.Column("gas", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column("gas_price", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column("max_fee_per_gas", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column( + "max_priority_fee_per_gas", sa.Numeric(precision=78, scale=0), nullable=True + ), + sa.Column("input", sa.Text(), nullable=True), + sa.Column("nonce", sa.VARCHAR(length=256), nullable=True), + sa.Column("transaction_index", sa.BigInteger(), nullable=True), + sa.Column("transaction_type", sa.Integer(), nullable=True), + sa.Column("value", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column( + "indexed_at", + sa.DateTime(timezone=True), + server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), + nullable=False, + ), + sa.ForeignKeyConstraint( + ["block_number"], + ["avalanche_blocks.block_number"], + name=op.f("fk_avalanche_transactions_block_number_avalanche_blocks"), + ondelete="CASCADE", + ), + sa.PrimaryKeyConstraint("hash", name=op.f("pk_avalanche_transactions")), + ) + op.create_index( + op.f("ix_avalanche_transactions_block_number"), + "avalanche_transactions", + ["block_number"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_transactions_from_address"), + "avalanche_transactions", + ["from_address"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_transactions_gas"), + "avalanche_transactions", + ["gas"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_transactions_gas_price"), + "avalanche_transactions", + ["gas_price"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_transactions_hash"), + "avalanche_transactions", + ["hash"], + unique=True, + ) + op.create_index( + op.f("ix_avalanche_transactions_to_address"), + "avalanche_transactions", + ["to_address"], + unique=False, + ) + op.create_index( + op.f("ix_avalanche_transactions_value"), + "avalanche_transactions", + ["value"], + unique=False, + ) + op.create_table( + "zksync_era_sepolia_transactions", + sa.Column("hash", sa.VARCHAR(length=256), nullable=False), + sa.Column("block_number", sa.BigInteger(), nullable=False), + sa.Column("from_address", sa.VARCHAR(length=256), nullable=True), + sa.Column("to_address", sa.VARCHAR(length=256), nullable=True), + sa.Column("gas", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column("gas_price", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column("max_fee_per_gas", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column( + "max_priority_fee_per_gas", sa.Numeric(precision=78, scale=0), nullable=True + ), + sa.Column("input", sa.Text(), nullable=True), + sa.Column("nonce", sa.VARCHAR(length=256), nullable=True), + sa.Column("transaction_index", sa.BigInteger(), nullable=True), + sa.Column("transaction_type", sa.Integer(), nullable=True), + sa.Column("value", sa.Numeric(precision=78, scale=0), nullable=True), + sa.Column( + "indexed_at", + sa.DateTime(timezone=True), + server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), + nullable=False, + ), + sa.Column("l1_batch_number", sa.BigInteger(), nullable=True), + sa.Column("l1_batch_tx_index", sa.BigInteger(), nullable=True), + sa.ForeignKeyConstraint( + ["block_number"], + ["zksync_era_sepolia_blocks.block_number"], + name=op.f( + "fk_zksync_era_sepolia_transactions_block_number_zksync_era_sepolia_blocks" + ), + ondelete="CASCADE", + ), + sa.PrimaryKeyConstraint( + "hash", name=op.f("pk_zksync_era_sepolia_transactions") + ), + ) + op.create_index( + op.f("ix_zksync_era_sepolia_transactions_block_number"), + "zksync_era_sepolia_transactions", + ["block_number"], + unique=False, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_transactions_from_address"), + "zksync_era_sepolia_transactions", + ["from_address"], + unique=False, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_transactions_gas"), + "zksync_era_sepolia_transactions", + ["gas"], + unique=False, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_transactions_gas_price"), + "zksync_era_sepolia_transactions", + ["gas_price"], + unique=False, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_transactions_hash"), + "zksync_era_sepolia_transactions", + ["hash"], + unique=True, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_transactions_to_address"), + "zksync_era_sepolia_transactions", + ["to_address"], + unique=False, + ) + op.create_index( + op.f("ix_zksync_era_sepolia_transactions_value"), + "zksync_era_sepolia_transactions", + ["value"], + unique=False, + ) + op.create_index( + "ix_arbitrum_nova_labels_address_block_number", + "arbitrum_nova_labels", + ["address", "block_number"], + unique=False, + ) + op.create_index( + "ix_arbitrum_nova_labels_address_block_timestamp", + "arbitrum_nova_labels", + ["address", "block_timestamp"], + unique=False, + ) + op.create_index( + "ix_arbitrum_sepolia_labels_address_block_number", + "arbitrum_sepolia_labels", + ["address", "block_number"], + unique=False, + ) + op.create_index( + "ix_arbitrum_sepolia_labels_address_block_timestamp", + "arbitrum_sepolia_labels", + ["address", "block_timestamp"], + unique=False, + ) + op.create_unique_constraint( + op.f("uq_arbitrum_sepolia_labels_id"), "arbitrum_sepolia_labels", ["id"] ) - op.create_index(op.f('ix_zksync_era_sepolia_transactions_block_number'), 'zksync_era_sepolia_transactions', ['block_number'], unique=False) - op.create_index(op.f('ix_zksync_era_sepolia_transactions_from_address'), 'zksync_era_sepolia_transactions', ['from_address'], unique=False) - op.create_index(op.f('ix_zksync_era_sepolia_transactions_gas'), 'zksync_era_sepolia_transactions', ['gas'], unique=False) - op.create_index(op.f('ix_zksync_era_sepolia_transactions_gas_price'), 'zksync_era_sepolia_transactions', ['gas_price'], unique=False) - op.create_index(op.f('ix_zksync_era_sepolia_transactions_hash'), 'zksync_era_sepolia_transactions', ['hash'], unique=True) - op.create_index(op.f('ix_zksync_era_sepolia_transactions_to_address'), 'zksync_era_sepolia_transactions', ['to_address'], unique=False) - op.create_index(op.f('ix_zksync_era_sepolia_transactions_value'), 'zksync_era_sepolia_transactions', ['value'], unique=False) - op.create_index('ix_arbitrum_nova_labels_address_block_number', 'arbitrum_nova_labels', ['address', 'block_number'], unique=False) - op.create_index('ix_arbitrum_nova_labels_address_block_timestamp', 'arbitrum_nova_labels', ['address', 'block_timestamp'], unique=False) - op.create_index('ix_arbitrum_sepolia_labels_address_block_number', 'arbitrum_sepolia_labels', ['address', 'block_number'], unique=False) - op.create_index('ix_arbitrum_sepolia_labels_address_block_timestamp', 'arbitrum_sepolia_labels', ['address', 'block_timestamp'], unique=False) - op.create_unique_constraint(op.f('uq_arbitrum_sepolia_labels_id'), 'arbitrum_sepolia_labels', ['id']) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(op.f('uq_zksync_era_testnet_labels_id'), 'zksync_era_testnet_labels', type_='unique') - op.drop_constraint(op.f('uq_zksync_era_labels_id'), 'zksync_era_labels', type_='unique') - op.drop_constraint(op.f('uq_xdai_labels_id'), 'xdai_labels', type_='unique') - op.drop_constraint(op.f('uq_xai_labels_id'), 'xai_labels', type_='unique') - op.drop_constraint(op.f('uq_wyrm_labels_id'), 'wyrm_labels', type_='unique') - op.drop_constraint(op.f('uq_polygon_labels_id'), 'polygon_labels', type_='unique') - op.drop_constraint(op.f('uq_opensea_crawler_state_id'), 'opensea_crawler_state', type_='unique') - op.drop_constraint(op.f('uq_mumbai_labels_id'), 'mumbai_labels', type_='unique') - op.create_index('idx_ethereum_labels_opensea_nft_name', 'ethereum_labels', [sa.text("(label_data ->> 'name'::text)")], unique=False) - op.drop_constraint(op.f('uq_arbitrum_sepolia_labels_id'), 'arbitrum_sepolia_labels', type_='unique') - op.drop_index('ix_arbitrum_sepolia_labels_address_block_timestamp', table_name='arbitrum_sepolia_labels') - op.drop_index('ix_arbitrum_sepolia_labels_address_block_number', table_name='arbitrum_sepolia_labels') - op.drop_index('ix_arbitrum_nova_labels_address_block_timestamp', table_name='arbitrum_nova_labels') - op.drop_index('ix_arbitrum_nova_labels_address_block_number', table_name='arbitrum_nova_labels') - op.drop_index(op.f('ix_zksync_era_sepolia_transactions_value'), table_name='zksync_era_sepolia_transactions') - op.drop_index(op.f('ix_zksync_era_sepolia_transactions_to_address'), table_name='zksync_era_sepolia_transactions') - op.drop_index(op.f('ix_zksync_era_sepolia_transactions_hash'), table_name='zksync_era_sepolia_transactions') - op.drop_index(op.f('ix_zksync_era_sepolia_transactions_gas_price'), table_name='zksync_era_sepolia_transactions') - op.drop_index(op.f('ix_zksync_era_sepolia_transactions_gas'), table_name='zksync_era_sepolia_transactions') - op.drop_index(op.f('ix_zksync_era_sepolia_transactions_from_address'), table_name='zksync_era_sepolia_transactions') - op.drop_index(op.f('ix_zksync_era_sepolia_transactions_block_number'), table_name='zksync_era_sepolia_transactions') - op.drop_table('zksync_era_sepolia_transactions') - op.drop_index(op.f('ix_avalanche_transactions_value'), table_name='avalanche_transactions') - op.drop_index(op.f('ix_avalanche_transactions_to_address'), table_name='avalanche_transactions') - op.drop_index(op.f('ix_avalanche_transactions_hash'), table_name='avalanche_transactions') - op.drop_index(op.f('ix_avalanche_transactions_gas_price'), table_name='avalanche_transactions') - op.drop_index(op.f('ix_avalanche_transactions_gas'), table_name='avalanche_transactions') - op.drop_index(op.f('ix_avalanche_transactions_from_address'), table_name='avalanche_transactions') - op.drop_index(op.f('ix_avalanche_transactions_block_number'), table_name='avalanche_transactions') - op.drop_table('avalanche_transactions') - op.drop_index(op.f('ix_avalanche_fuji_transactions_value'), table_name='avalanche_fuji_transactions') - op.drop_index(op.f('ix_avalanche_fuji_transactions_to_address'), table_name='avalanche_fuji_transactions') - op.drop_index(op.f('ix_avalanche_fuji_transactions_hash'), table_name='avalanche_fuji_transactions') - op.drop_index(op.f('ix_avalanche_fuji_transactions_gas_price'), table_name='avalanche_fuji_transactions') - op.drop_index(op.f('ix_avalanche_fuji_transactions_gas'), table_name='avalanche_fuji_transactions') - op.drop_index(op.f('ix_avalanche_fuji_transactions_from_address'), table_name='avalanche_fuji_transactions') - op.drop_index(op.f('ix_avalanche_fuji_transactions_block_number'), table_name='avalanche_fuji_transactions') - op.drop_table('avalanche_fuji_transactions') - op.drop_index(op.f('ix_zksync_era_sepolia_labels_transaction_hash'), table_name='zksync_era_sepolia_labels') - op.drop_index(op.f('ix_zksync_era_sepolia_labels_label'), table_name='zksync_era_sepolia_labels') - op.drop_index(op.f('ix_zksync_era_sepolia_labels_block_timestamp'), table_name='zksync_era_sepolia_labels') - op.drop_index(op.f('ix_zksync_era_sepolia_labels_block_number'), table_name='zksync_era_sepolia_labels') - op.drop_index('ix_zksync_era_sepolia_labels_address_block_timestamp', table_name='zksync_era_sepolia_labels') - op.drop_index('ix_zksync_era_sepolia_labels_address_block_number', table_name='zksync_era_sepolia_labels') - op.drop_index(op.f('ix_zksync_era_sepolia_labels_address'), table_name='zksync_era_sepolia_labels') - op.drop_table('zksync_era_sepolia_labels') - op.drop_index(op.f('ix_zksync_era_sepolia_blocks_timestamp'), table_name='zksync_era_sepolia_blocks') - op.drop_index(op.f('ix_zksync_era_sepolia_blocks_hash'), table_name='zksync_era_sepolia_blocks') - op.drop_index(op.f('ix_zksync_era_sepolia_blocks_block_number'), table_name='zksync_era_sepolia_blocks') - op.drop_table('zksync_era_sepolia_blocks') - op.drop_index(op.f('ix_avalanche_labels_transaction_hash'), table_name='avalanche_labels') - op.drop_index(op.f('ix_avalanche_labels_label'), table_name='avalanche_labels') - op.drop_index(op.f('ix_avalanche_labels_block_timestamp'), table_name='avalanche_labels') - op.drop_index(op.f('ix_avalanche_labels_block_number'), table_name='avalanche_labels') - op.drop_index('ix_avalanche_labels_address_block_timestamp', table_name='avalanche_labels') - op.drop_index('ix_avalanche_labels_address_block_number', table_name='avalanche_labels') - op.drop_index(op.f('ix_avalanche_labels_address'), table_name='avalanche_labels') - op.drop_table('avalanche_labels') - op.drop_index(op.f('ix_avalanche_fuji_labels_transaction_hash'), table_name='avalanche_fuji_labels') - op.drop_index(op.f('ix_avalanche_fuji_labels_label'), table_name='avalanche_fuji_labels') - op.drop_index(op.f('ix_avalanche_fuji_labels_block_timestamp'), table_name='avalanche_fuji_labels') - op.drop_index(op.f('ix_avalanche_fuji_labels_block_number'), table_name='avalanche_fuji_labels') - op.drop_index('ix_avalanche_fuji_labels_address_block_timestamp', table_name='avalanche_fuji_labels') - op.drop_index('ix_avalanche_fuji_labels_address_block_number', table_name='avalanche_fuji_labels') - op.drop_index(op.f('ix_avalanche_fuji_labels_address'), table_name='avalanche_fuji_labels') - op.drop_table('avalanche_fuji_labels') - op.drop_index(op.f('ix_avalanche_fuji_blocks_timestamp'), table_name='avalanche_fuji_blocks') - op.drop_index(op.f('ix_avalanche_fuji_blocks_hash'), table_name='avalanche_fuji_blocks') - op.drop_index(op.f('ix_avalanche_fuji_blocks_block_number'), table_name='avalanche_fuji_blocks') - op.drop_table('avalanche_fuji_blocks') - op.drop_index(op.f('ix_avalanche_blocks_timestamp'), table_name='avalanche_blocks') - op.drop_index(op.f('ix_avalanche_blocks_hash'), table_name='avalanche_blocks') - op.drop_index(op.f('ix_avalanche_blocks_block_number'), table_name='avalanche_blocks') - op.drop_table('avalanche_blocks') + op.drop_constraint( + op.f("uq_zksync_era_testnet_labels_id"), + "zksync_era_testnet_labels", + type_="unique", + ) + op.drop_constraint( + op.f("uq_zksync_era_labels_id"), "zksync_era_labels", type_="unique" + ) + op.drop_constraint(op.f("uq_xdai_labels_id"), "xdai_labels", type_="unique") + # op.drop_constraint(op.f('uq_xai_labels_id'), 'xai_labels', type_='unique') + op.drop_constraint(op.f("uq_wyrm_labels_id"), "wyrm_labels", type_="unique") + op.drop_constraint(op.f("uq_polygon_labels_id"), "polygon_labels", type_="unique") + op.drop_constraint( + op.f("uq_opensea_crawler_state_id"), "opensea_crawler_state", type_="unique" + ) + op.drop_constraint(op.f("uq_mumbai_labels_id"), "mumbai_labels", type_="unique") + op.create_index( + "idx_ethereum_labels_opensea_nft_name", + "ethereum_labels", + [sa.text("(label_data ->> 'name'::text)")], + unique=False, + ) + op.drop_constraint( + op.f("uq_arbitrum_sepolia_labels_id"), "arbitrum_sepolia_labels", type_="unique" + ) + op.drop_index( + "ix_arbitrum_sepolia_labels_address_block_timestamp", + table_name="arbitrum_sepolia_labels", + ) + op.drop_index( + "ix_arbitrum_sepolia_labels_address_block_number", + table_name="arbitrum_sepolia_labels", + ) + op.drop_index( + "ix_arbitrum_nova_labels_address_block_timestamp", + table_name="arbitrum_nova_labels", + ) + op.drop_index( + "ix_arbitrum_nova_labels_address_block_number", + table_name="arbitrum_nova_labels", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_transactions_value"), + table_name="zksync_era_sepolia_transactions", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_transactions_to_address"), + table_name="zksync_era_sepolia_transactions", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_transactions_hash"), + table_name="zksync_era_sepolia_transactions", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_transactions_gas_price"), + table_name="zksync_era_sepolia_transactions", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_transactions_gas"), + table_name="zksync_era_sepolia_transactions", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_transactions_from_address"), + table_name="zksync_era_sepolia_transactions", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_transactions_block_number"), + table_name="zksync_era_sepolia_transactions", + ) + op.drop_table("zksync_era_sepolia_transactions") + op.drop_index( + op.f("ix_avalanche_transactions_value"), table_name="avalanche_transactions" + ) + op.drop_index( + op.f("ix_avalanche_transactions_to_address"), + table_name="avalanche_transactions", + ) + op.drop_index( + op.f("ix_avalanche_transactions_hash"), table_name="avalanche_transactions" + ) + op.drop_index( + op.f("ix_avalanche_transactions_gas_price"), table_name="avalanche_transactions" + ) + op.drop_index( + op.f("ix_avalanche_transactions_gas"), table_name="avalanche_transactions" + ) + op.drop_index( + op.f("ix_avalanche_transactions_from_address"), + table_name="avalanche_transactions", + ) + op.drop_index( + op.f("ix_avalanche_transactions_block_number"), + table_name="avalanche_transactions", + ) + op.drop_table("avalanche_transactions") + op.drop_index( + op.f("ix_avalanche_fuji_transactions_value"), + table_name="avalanche_fuji_transactions", + ) + op.drop_index( + op.f("ix_avalanche_fuji_transactions_to_address"), + table_name="avalanche_fuji_transactions", + ) + op.drop_index( + op.f("ix_avalanche_fuji_transactions_hash"), + table_name="avalanche_fuji_transactions", + ) + op.drop_index( + op.f("ix_avalanche_fuji_transactions_gas_price"), + table_name="avalanche_fuji_transactions", + ) + op.drop_index( + op.f("ix_avalanche_fuji_transactions_gas"), + table_name="avalanche_fuji_transactions", + ) + op.drop_index( + op.f("ix_avalanche_fuji_transactions_from_address"), + table_name="avalanche_fuji_transactions", + ) + op.drop_index( + op.f("ix_avalanche_fuji_transactions_block_number"), + table_name="avalanche_fuji_transactions", + ) + op.drop_table("avalanche_fuji_transactions") + op.drop_index( + op.f("ix_zksync_era_sepolia_labels_transaction_hash"), + table_name="zksync_era_sepolia_labels", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_labels_label"), + table_name="zksync_era_sepolia_labels", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_labels_block_timestamp"), + table_name="zksync_era_sepolia_labels", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_labels_block_number"), + table_name="zksync_era_sepolia_labels", + ) + op.drop_index( + "ix_zksync_era_sepolia_labels_address_block_timestamp", + table_name="zksync_era_sepolia_labels", + ) + op.drop_index( + "ix_zksync_era_sepolia_labels_address_block_number", + table_name="zksync_era_sepolia_labels", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_labels_address"), + table_name="zksync_era_sepolia_labels", + ) + op.drop_table("zksync_era_sepolia_labels") + op.drop_index( + op.f("ix_zksync_era_sepolia_blocks_timestamp"), + table_name="zksync_era_sepolia_blocks", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_blocks_hash"), + table_name="zksync_era_sepolia_blocks", + ) + op.drop_index( + op.f("ix_zksync_era_sepolia_blocks_block_number"), + table_name="zksync_era_sepolia_blocks", + ) + op.drop_table("zksync_era_sepolia_blocks") + op.drop_index( + op.f("ix_avalanche_labels_transaction_hash"), table_name="avalanche_labels" + ) + op.drop_index(op.f("ix_avalanche_labels_label"), table_name="avalanche_labels") + op.drop_index( + op.f("ix_avalanche_labels_block_timestamp"), table_name="avalanche_labels" + ) + op.drop_index( + op.f("ix_avalanche_labels_block_number"), table_name="avalanche_labels" + ) + op.drop_index( + "ix_avalanche_labels_address_block_timestamp", table_name="avalanche_labels" + ) + op.drop_index( + "ix_avalanche_labels_address_block_number", table_name="avalanche_labels" + ) + op.drop_index(op.f("ix_avalanche_labels_address"), table_name="avalanche_labels") + op.drop_table("avalanche_labels") + op.drop_index( + op.f("ix_avalanche_fuji_labels_transaction_hash"), + table_name="avalanche_fuji_labels", + ) + op.drop_index( + op.f("ix_avalanche_fuji_labels_label"), table_name="avalanche_fuji_labels" + ) + op.drop_index( + op.f("ix_avalanche_fuji_labels_block_timestamp"), + table_name="avalanche_fuji_labels", + ) + op.drop_index( + op.f("ix_avalanche_fuji_labels_block_number"), + table_name="avalanche_fuji_labels", + ) + op.drop_index( + "ix_avalanche_fuji_labels_address_block_timestamp", + table_name="avalanche_fuji_labels", + ) + op.drop_index( + "ix_avalanche_fuji_labels_address_block_number", + table_name="avalanche_fuji_labels", + ) + op.drop_index( + op.f("ix_avalanche_fuji_labels_address"), table_name="avalanche_fuji_labels" + ) + op.drop_table("avalanche_fuji_labels") + op.drop_index( + op.f("ix_avalanche_fuji_blocks_timestamp"), table_name="avalanche_fuji_blocks" + ) + op.drop_index( + op.f("ix_avalanche_fuji_blocks_hash"), table_name="avalanche_fuji_blocks" + ) + op.drop_index( + op.f("ix_avalanche_fuji_blocks_block_number"), + table_name="avalanche_fuji_blocks", + ) + op.drop_table("avalanche_fuji_blocks") + op.drop_index(op.f("ix_avalanche_blocks_timestamp"), table_name="avalanche_blocks") + op.drop_index(op.f("ix_avalanche_blocks_hash"), table_name="avalanche_blocks") + op.drop_index( + op.f("ix_avalanche_blocks_block_number"), table_name="avalanche_blocks" + ) + op.drop_table("avalanche_blocks") # ### end Alembic commands ### diff --git a/moonstreamdb/moonstreamdb/blockchain.py b/moonstreamdb/moonstreamdb/blockchain.py index 885d2b1f..9bbfa1f0 100644 --- a/moonstreamdb/moonstreamdb/blockchain.py +++ b/moonstreamdb/moonstreamdb/blockchain.py @@ -77,7 +77,7 @@ class AvailableBlockchainType(Enum): AVALANCHE_FUJI = "avalanche_fuji" BLAST = "blast" BLAST_SEPOLIA = "blast_sepolia" - PROOF_OF_PLAY_APEX = "proof_of_play_apex" + PROOFOFPLAY_APEX = "proofofplay_apex" def get_block_model( @@ -163,7 +163,7 @@ def get_block_model( block_model = BlastBlock elif blockchain_type == AvailableBlockchainType.BLAST_SEPOLIA: block_model = BlastSepoliaBlock - elif blockchain_type == AvailableBlockchainType.PROOF_OF_PLAY_APEX: + elif blockchain_type == AvailableBlockchainType.PROOFOFPLAY_APEX: block_model = ProofOfPlayApexBlock else: raise Exception("Unsupported blockchain type provided") @@ -254,7 +254,7 @@ def get_label_model( label_model = BlastLabel elif blockchain_type == AvailableBlockchainType.BLAST_SEPOLIA: label_model = BlastSepoliaLabel - elif blockchain_type == AvailableBlockchainType.PROOF_OF_PLAY_APEX: + elif blockchain_type == AvailableBlockchainType.PROOFOFPLAY_APEX: label_model = ProofOfPlayApexLabel else: raise Exception("Unsupported blockchain type provided") @@ -345,7 +345,7 @@ def get_transaction_model( transaction_model = BlastTransaction elif blockchain_type == AvailableBlockchainType.BLAST_SEPOLIA: transaction_model = BlastSepoliaTransaction - elif blockchain_type == AvailableBlockchainType.PROOF_OF_PLAY_APEX: + elif blockchain_type == AvailableBlockchainType.PROOFOFPLAY_APEX: transaction_model = ProofOfPlayApexTransaction else: raise Exception("Unsupported blockchain type provided") diff --git a/moonstreamdb/moonstreamdb/models.py b/moonstreamdb/moonstreamdb/models.py index 95ff51d8..2426604e 100644 --- a/moonstreamdb/moonstreamdb/models.py +++ b/moonstreamdb/moonstreamdb/models.py @@ -1937,7 +1937,7 @@ class BlastSepoliaLabel(Base): # type: ignore class ProofOfPlayApexBlock(Base): # type: ignore - __tablename__ = "proof_of_play_apex_blocks" + __tablename__ = "proofofplay_apex_blocks" block_number = Column( BigInteger, primary_key=True, unique=True, nullable=False, index=True @@ -1971,14 +1971,14 @@ class ProofOfPlayApexBlock(Base): # type: ignore class ProofOfPlayApexTransaction(Base): # type: ignore - __tablename__ = "proof_of_play_apex_transactions" + __tablename__ = "proofofplay_apex_transactions" hash = Column( VARCHAR(256), primary_key=True, unique=True, nullable=False, index=True ) block_number = Column( BigInteger, - ForeignKey("proof_of_play_apex_blocks.block_number", ondelete="CASCADE"), + ForeignKey("proofofplay_apex_blocks.block_number", ondelete="CASCADE"), nullable=False, index=True, ) @@ -2002,17 +2002,17 @@ class ProofOfPlayApexTransaction(Base): # type: ignore class ProofOfPlayApexLabel(Base): # type: ignore - __tablename__ = "proof_of_play_apex_labels" + __tablename__ = "proofofplay_apex_labels" __table_args__ = ( Index( - "ix_proof_of_play_apex_labels_address_block_number", + "ix_proofofplay_apex_labels_address_block_number", "address", "block_number", unique=False, ), Index( - "ix_proof_of_play_apex_labels_address_block_timestamp", + "ix_proofofplay_apex_labels_address_block_timestamp", "address", "block_timestamp", unique=False, diff --git a/moonstreamdb/moonstreamdb/networks.py b/moonstreamdb/moonstreamdb/networks.py index 9a1e5d18..b63e2d04 100644 --- a/moonstreamdb/moonstreamdb/networks.py +++ b/moonstreamdb/moonstreamdb/networks.py @@ -79,7 +79,7 @@ class Network(Enum): avalanche_fuji = "avalanche_fuji" blast = "blast" blast_sepolia = "blast_sepolia" - proof_of_play_apex = "proof_of_play_apex" + proofofplay_apex = "proofofplay_apex" tx_raw_types = Union[ @@ -189,7 +189,7 @@ MODELS: Dict[Network, Dict[str, Base]] = { "labels": BlastSepoliaLabel, "transactions": BlastSepoliaTransaction, }, - Network.proof_of_play_apex: { + Network.proofofplay_apex: { "blocks": ProofOfPlayApexBlock, "labels": ProofOfPlayApexLabel, "transactions": ProofOfPlayApexTransaction, @@ -235,6 +235,6 @@ def blockchain_type_to_network_type( elif blockchain_type == AvailableBlockchainType.BLAST_SEPOLIA: return Network.blast_sepolia elif blockchain_type == AvailableBlockchainType.PROOF_OF_PLAY_APEX: - return Network.proof_of_play_apex + return Network.proofofplay_apex else: raise ValueError(f"Unknown blockchain type: {blockchain_type}") diff --git a/moonstreamdb/moonstreamdb/subscriptions.py b/moonstreamdb/moonstreamdb/subscriptions.py index 54e50c61..3b567249 100644 --- a/moonstreamdb/moonstreamdb/subscriptions.py +++ b/moonstreamdb/moonstreamdb/subscriptions.py @@ -21,7 +21,7 @@ class SubscriptionTypes(Enum): AVALANCHE_FUJI_BLOCKCHAIN = "avalanche_fuji_smartcontract" BLAST_BLOCKCHAIN = "blast_smartcontract" BLAST_SEPOLIA_BLOCKCHAIN = "blast_sepolia_smartcontract" - PROOF_OF_PLAY_APEX_BLOCKCHAIN = "proof_of_play_apex_smartcontract" + PROOFOFPLAY_APEX_BLOCKCHAIN = "proofofplay_apex_smartcontract" def blockchain_type_to_subscription_type( @@ -61,8 +61,8 @@ def blockchain_type_to_subscription_type( return SubscriptionTypes.BLAST_BLOCKCHAIN elif blockchain_type == AvailableBlockchainType.BLAST_SEPOLIA: return SubscriptionTypes.BLAST_SEPOLIA_BLOCKCHAIN - elif blockchain_type == AvailableBlockchainType.PROOF_OF_PLAY_APEX: - return SubscriptionTypes.PROOF_OF_PLAY_APEX_BLOCKCHAIN + elif blockchain_type == AvailableBlockchainType.PROOFOFPLAY_APEX: + return SubscriptionTypes.PROOFOFPLAY_APEX_BLOCKCHAIN else: raise ValueError(f"Unknown blockchain type: {blockchain_type}") @@ -85,7 +85,7 @@ subscription_id_by_blockchain = { "avalanche_fuji": "avalanche_fuji_smartcontract", "blast": "blast_smartcontract", "blast_sepolia": "blast_sepolia_smartcontract", - "proof_of_play_apex": "proof_of_play_apex_smartcontract", + "proofofplay_apex": "proofofplay_apex_smartcontract", } blockchain_by_subscription_id = { @@ -106,7 +106,7 @@ blockchain_by_subscription_id = { "avalanche_fuji_blockchain": "avalanche_fuji", "blast_blockchain": "blast", "blast_sepolia_blockchain": "blast_sepolia", - "proof_of_play_apex_blockchain": "proof_of_play_apex", + "proofofplay_apex_blockchain": "proofofplay_apex", "ethereum_smartcontract": "ethereum", "polygon_smartcontract": "polygon", "mumbai_smartcontract": "mumbai", @@ -124,5 +124,5 @@ blockchain_by_subscription_id = { "avalanche_fuji_smartcontract": "avalanche_fuji", "blast_smartcontract": "blast", "blast_sepolia_smartcontract": "blast_sepolia", - "proof_of_play_apex_smartcontract": "proof_of_play_apex", + "proofofplay_apex_smartcontract": "proofofplay_apex", }