"""Add contracts tables

Revision ID: 82ff1541f4b4
Revises: c1bc596631f9
Create Date: 2024-11-04 14:29:45.303216

"""

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 = "82ff1541f4b4"
down_revision: Union[str, None] = "c1bc596631f9"
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(
        "bytecode_storage",
        sa.Column("id", sa.UUID(), nullable=False),
        sa.Column("hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode", sa.Text(), nullable=False),
        sa.Column("title", sa.VARCHAR(length=256), nullable=True),
        sa.Column("description", sa.Text(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("code", sa.Text(), nullable=True),
        sa.Column("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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.PrimaryKeyConstraint("id", name=op.f("pk_bytecode_storage")),
        sa.UniqueConstraint("hash", name="uq_bytecode_storage_hash"),
    )
    op.create_index(
        op.f("ix_bytecode_storage_hash"), "bytecode_storage", ["hash"], unique=False
    )
    op.create_table(
        "arbitrum_one_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f("fk_arbitrum_one_contracts_bytecode_storage_id_bytecode_storage"),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_arbitrum_one_contracts")),
    )
    op.create_index(
        op.f("ix_arbitrum_one_contracts_deployed_bytecode_hash"),
        "arbitrum_one_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_arbitrum_one_contracts_name"),
        "arbitrum_one_contracts",
        ["name"],
        unique=False,
    )
    op.create_index(
        op.f("ix_arbitrum_one_contracts_transaction_hash"),
        "arbitrum_one_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "arbitrum_sepolia_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f(
                "fk_arbitrum_sepolia_contracts_bytecode_storage_id_bytecode_storage"
            ),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_arbitrum_sepolia_contracts")),
    )
    op.create_index(
        op.f("ix_arbitrum_sepolia_contracts_deployed_bytecode_hash"),
        "arbitrum_sepolia_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_arbitrum_sepolia_contracts_name"),
        "arbitrum_sepolia_contracts",
        ["name"],
        unique=False,
    )
    op.create_index(
        op.f("ix_arbitrum_sepolia_contracts_transaction_hash"),
        "arbitrum_sepolia_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "b3_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f("fk_b3_contracts_bytecode_storage_id_bytecode_storage"),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_b3_contracts")),
    )
    op.create_index(
        op.f("ix_b3_contracts_deployed_bytecode_hash"),
        "b3_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_b3_contracts_name"), "b3_contracts", ["name"], unique=False
    )
    op.create_index(
        op.f("ix_b3_contracts_transaction_hash"),
        "b3_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "b3_sepolia_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f("fk_b3_sepolia_contracts_bytecode_storage_id_bytecode_storage"),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_b3_sepolia_contracts")),
    )
    op.create_index(
        op.f("ix_b3_sepolia_contracts_deployed_bytecode_hash"),
        "b3_sepolia_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_b3_sepolia_contracts_name"),
        "b3_sepolia_contracts",
        ["name"],
        unique=False,
    )
    op.create_index(
        op.f("ix_b3_sepolia_contracts_transaction_hash"),
        "b3_sepolia_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "ethereum_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f("fk_ethereum_contracts_bytecode_storage_id_bytecode_storage"),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_ethereum_contracts")),
    )
    op.create_index(
        op.f("ix_ethereum_contracts_deployed_bytecode_hash"),
        "ethereum_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_ethereum_contracts_name"), "ethereum_contracts", ["name"], unique=False
    )
    op.create_index(
        op.f("ix_ethereum_contracts_transaction_hash"),
        "ethereum_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "game7_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f("fk_game7_contracts_bytecode_storage_id_bytecode_storage"),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_game7_contracts")),
    )
    op.create_index(
        op.f("ix_game7_contracts_deployed_bytecode_hash"),
        "game7_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_game7_contracts_name"), "game7_contracts", ["name"], unique=False
    )
    op.create_index(
        op.f("ix_game7_contracts_transaction_hash"),
        "game7_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "game7_orbit_arbitrum_sepolia_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f(
                "fk_game7_orbit_arbitrum_sepolia_contracts_bytecode_storage_id_bytecode_storage"
            ),
        ),
        sa.PrimaryKeyConstraint(
            "address", name=op.f("pk_game7_orbit_arbitrum_sepolia_contracts")
        ),
    )
    op.create_index(
        op.f("ix_game7_orbit_arbitrum_sepolia_contracts_deployed_bytecode_hash"),
        "game7_orbit_arbitrum_sepolia_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_game7_orbit_arbitrum_sepolia_contracts_name"),
        "game7_orbit_arbitrum_sepolia_contracts",
        ["name"],
        unique=False,
    )
    op.create_index(
        op.f("ix_game7_orbit_arbitrum_sepolia_contracts_transaction_hash"),
        "game7_orbit_arbitrum_sepolia_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "game7_testnet_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f(
                "fk_game7_testnet_contracts_bytecode_storage_id_bytecode_storage"
            ),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_game7_testnet_contracts")),
    )
    op.create_index(
        op.f("ix_game7_testnet_contracts_deployed_bytecode_hash"),
        "game7_testnet_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_game7_testnet_contracts_name"),
        "game7_testnet_contracts",
        ["name"],
        unique=False,
    )
    op.create_index(
        op.f("ix_game7_testnet_contracts_transaction_hash"),
        "game7_testnet_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "imx_zkevm_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f("fk_imx_zkevm_contracts_bytecode_storage_id_bytecode_storage"),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_imx_zkevm_contracts")),
    )
    op.create_index(
        op.f("ix_imx_zkevm_contracts_deployed_bytecode_hash"),
        "imx_zkevm_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_imx_zkevm_contracts_name"),
        "imx_zkevm_contracts",
        ["name"],
        unique=False,
    )
    op.create_index(
        op.f("ix_imx_zkevm_contracts_transaction_hash"),
        "imx_zkevm_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "imx_zkevm_sepolia_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f(
                "fk_imx_zkevm_sepolia_contracts_bytecode_storage_id_bytecode_storage"
            ),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_imx_zkevm_sepolia_contracts")),
    )
    op.create_index(
        op.f("ix_imx_zkevm_sepolia_contracts_deployed_bytecode_hash"),
        "imx_zkevm_sepolia_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_imx_zkevm_sepolia_contracts_name"),
        "imx_zkevm_sepolia_contracts",
        ["name"],
        unique=False,
    )
    op.create_index(
        op.f("ix_imx_zkevm_sepolia_contracts_transaction_hash"),
        "imx_zkevm_sepolia_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "mantle_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f("fk_mantle_contracts_bytecode_storage_id_bytecode_storage"),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_mantle_contracts")),
    )
    op.create_index(
        op.f("ix_mantle_contracts_deployed_bytecode_hash"),
        "mantle_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_mantle_contracts_name"), "mantle_contracts", ["name"], unique=False
    )
    op.create_index(
        op.f("ix_mantle_contracts_transaction_hash"),
        "mantle_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "mantle_sepolia_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f(
                "fk_mantle_sepolia_contracts_bytecode_storage_id_bytecode_storage"
            ),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_mantle_sepolia_contracts")),
    )
    op.create_index(
        op.f("ix_mantle_sepolia_contracts_deployed_bytecode_hash"),
        "mantle_sepolia_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_mantle_sepolia_contracts_name"),
        "mantle_sepolia_contracts",
        ["name"],
        unique=False,
    )
    op.create_index(
        op.f("ix_mantle_sepolia_contracts_transaction_hash"),
        "mantle_sepolia_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "polygon_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f("fk_polygon_contracts_bytecode_storage_id_bytecode_storage"),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_polygon_contracts")),
    )
    op.create_index(
        op.f("ix_polygon_contracts_deployed_bytecode_hash"),
        "polygon_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_polygon_contracts_name"), "polygon_contracts", ["name"], unique=False
    )
    op.create_index(
        op.f("ix_polygon_contracts_transaction_hash"),
        "polygon_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "sepolia_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f("fk_sepolia_contracts_bytecode_storage_id_bytecode_storage"),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_sepolia_contracts")),
    )
    op.create_index(
        op.f("ix_sepolia_contracts_deployed_bytecode_hash"),
        "sepolia_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_sepolia_contracts_name"), "sepolia_contracts", ["name"], unique=False
    )
    op.create_index(
        op.f("ix_sepolia_contracts_transaction_hash"),
        "sepolia_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "xai_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f("fk_xai_contracts_bytecode_storage_id_bytecode_storage"),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_xai_contracts")),
    )
    op.create_index(
        op.f("ix_xai_contracts_deployed_bytecode_hash"),
        "xai_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_xai_contracts_name"), "xai_contracts", ["name"], unique=False
    )
    op.create_index(
        op.f("ix_xai_contracts_transaction_hash"),
        "xai_contracts",
        ["transaction_hash"],
        unique=False,
    )
    op.create_table(
        "xai_sepolia_contracts",
        sa.Column("address", sa.LargeBinary(length=20), nullable=False),
        sa.Column("deployed_bytecode", sa.Text(), nullable=False),
        sa.Column("deployed_bytecode_hash", sa.VARCHAR(length=32), nullable=False),
        sa.Column("bytecode_storage_id", sa.UUID(), nullable=True),
        sa.Column("abi", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column("deployed_at_block_number", sa.BigInteger(), nullable=False),
        sa.Column("deployed_at_block_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("deployed_at_block_timestamp", sa.BigInteger(), nullable=False),
        sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
        sa.Column("transaction_index", sa.BigInteger(), nullable=False),
        sa.Column("name", sa.VARCHAR(length=256), nullable=True),
        sa.Column("statistics", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
        sa.Column(
            "supported_standards",
            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.Column(
            "updated_at",
            sa.DateTime(timezone=True),
            server_default=sa.text("TIMEZONE('utc', statement_timestamp())"),
            nullable=False,
        ),
        sa.ForeignKeyConstraint(
            ["bytecode_storage_id"],
            ["bytecode_storage.id"],
            name=op.f("fk_xai_sepolia_contracts_bytecode_storage_id_bytecode_storage"),
        ),
        sa.PrimaryKeyConstraint("address", name=op.f("pk_xai_sepolia_contracts")),
    )
    op.create_index(
        op.f("ix_xai_sepolia_contracts_deployed_bytecode_hash"),
        "xai_sepolia_contracts",
        ["deployed_bytecode_hash"],
        unique=False,
    )
    op.create_index(
        op.f("ix_xai_sepolia_contracts_name"),
        "xai_sepolia_contracts",
        ["name"],
        unique=False,
    )
    op.create_index(
        op.f("ix_xai_sepolia_contracts_transaction_hash"),
        "xai_sepolia_contracts",
        ["transaction_hash"],
        unique=False,
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(
        op.f("ix_xai_sepolia_contracts_transaction_hash"),
        table_name="xai_sepolia_contracts",
    )
    op.drop_index(
        op.f("ix_xai_sepolia_contracts_name"), table_name="xai_sepolia_contracts"
    )
    op.drop_index(
        op.f("ix_xai_sepolia_contracts_deployed_bytecode_hash"),
        table_name="xai_sepolia_contracts",
    )
    op.drop_table("xai_sepolia_contracts")
    op.drop_index(op.f("ix_xai_contracts_transaction_hash"), table_name="xai_contracts")
    op.drop_index(op.f("ix_xai_contracts_name"), table_name="xai_contracts")
    op.drop_index(
        op.f("ix_xai_contracts_deployed_bytecode_hash"), table_name="xai_contracts"
    )
    op.drop_table("xai_contracts")
    op.drop_index(
        op.f("ix_sepolia_contracts_transaction_hash"), table_name="sepolia_contracts"
    )
    op.drop_index(op.f("ix_sepolia_contracts_name"), table_name="sepolia_contracts")
    op.drop_index(
        op.f("ix_sepolia_contracts_deployed_bytecode_hash"),
        table_name="sepolia_contracts",
    )
    op.drop_table("sepolia_contracts")
    op.drop_index(
        op.f("ix_polygon_contracts_transaction_hash"), table_name="polygon_contracts"
    )
    op.drop_index(op.f("ix_polygon_contracts_name"), table_name="polygon_contracts")
    op.drop_index(
        op.f("ix_polygon_contracts_deployed_bytecode_hash"),
        table_name="polygon_contracts",
    )
    op.drop_table("polygon_contracts")
    op.drop_index(
        op.f("ix_mantle_sepolia_contracts_transaction_hash"),
        table_name="mantle_sepolia_contracts",
    )
    op.drop_index(
        op.f("ix_mantle_sepolia_contracts_name"), table_name="mantle_sepolia_contracts"
    )
    op.drop_index(
        op.f("ix_mantle_sepolia_contracts_deployed_bytecode_hash"),
        table_name="mantle_sepolia_contracts",
    )
    op.drop_table("mantle_sepolia_contracts")
    op.drop_index(
        op.f("ix_mantle_contracts_transaction_hash"), table_name="mantle_contracts"
    )
    op.drop_index(op.f("ix_mantle_contracts_name"), table_name="mantle_contracts")
    op.drop_index(
        op.f("ix_mantle_contracts_deployed_bytecode_hash"),
        table_name="mantle_contracts",
    )
    op.drop_table("mantle_contracts")
    op.drop_index(
        op.f("ix_imx_zkevm_sepolia_contracts_transaction_hash"),
        table_name="imx_zkevm_sepolia_contracts",
    )
    op.drop_index(
        op.f("ix_imx_zkevm_sepolia_contracts_name"),
        table_name="imx_zkevm_sepolia_contracts",
    )
    op.drop_index(
        op.f("ix_imx_zkevm_sepolia_contracts_deployed_bytecode_hash"),
        table_name="imx_zkevm_sepolia_contracts",
    )
    op.drop_table("imx_zkevm_sepolia_contracts")
    op.drop_index(
        op.f("ix_imx_zkevm_contracts_transaction_hash"),
        table_name="imx_zkevm_contracts",
    )
    op.drop_index(op.f("ix_imx_zkevm_contracts_name"), table_name="imx_zkevm_contracts")
    op.drop_index(
        op.f("ix_imx_zkevm_contracts_deployed_bytecode_hash"),
        table_name="imx_zkevm_contracts",
    )
    op.drop_table("imx_zkevm_contracts")
    op.drop_index(
        op.f("ix_game7_testnet_contracts_transaction_hash"),
        table_name="game7_testnet_contracts",
    )
    op.drop_index(
        op.f("ix_game7_testnet_contracts_name"), table_name="game7_testnet_contracts"
    )
    op.drop_index(
        op.f("ix_game7_testnet_contracts_deployed_bytecode_hash"),
        table_name="game7_testnet_contracts",
    )
    op.drop_table("game7_testnet_contracts")
    op.drop_index(
        op.f("ix_game7_orbit_arbitrum_sepolia_contracts_transaction_hash"),
        table_name="game7_orbit_arbitrum_sepolia_contracts",
    )
    op.drop_index(
        op.f("ix_game7_orbit_arbitrum_sepolia_contracts_name"),
        table_name="game7_orbit_arbitrum_sepolia_contracts",
    )
    op.drop_index(
        op.f("ix_game7_orbit_arbitrum_sepolia_contracts_deployed_bytecode_hash"),
        table_name="game7_orbit_arbitrum_sepolia_contracts",
    )
    op.drop_table("game7_orbit_arbitrum_sepolia_contracts")
    op.drop_index(
        op.f("ix_game7_contracts_transaction_hash"), table_name="game7_contracts"
    )
    op.drop_index(op.f("ix_game7_contracts_name"), table_name="game7_contracts")
    op.drop_index(
        op.f("ix_game7_contracts_deployed_bytecode_hash"), table_name="game7_contracts"
    )
    op.drop_table("game7_contracts")
    op.drop_index(
        op.f("ix_ethereum_contracts_transaction_hash"), table_name="ethereum_contracts"
    )
    op.drop_index(op.f("ix_ethereum_contracts_name"), table_name="ethereum_contracts")
    op.drop_index(
        op.f("ix_ethereum_contracts_deployed_bytecode_hash"),
        table_name="ethereum_contracts",
    )
    op.drop_table("ethereum_contracts")
    op.drop_index(
        op.f("ix_b3_sepolia_contracts_transaction_hash"),
        table_name="b3_sepolia_contracts",
    )
    op.drop_index(
        op.f("ix_b3_sepolia_contracts_name"), table_name="b3_sepolia_contracts"
    )
    op.drop_index(
        op.f("ix_b3_sepolia_contracts_deployed_bytecode_hash"),
        table_name="b3_sepolia_contracts",
    )
    op.drop_table("b3_sepolia_contracts")
    op.drop_index(op.f("ix_b3_contracts_transaction_hash"), table_name="b3_contracts")
    op.drop_index(op.f("ix_b3_contracts_name"), table_name="b3_contracts")
    op.drop_index(
        op.f("ix_b3_contracts_deployed_bytecode_hash"), table_name="b3_contracts"
    )
    op.drop_table("b3_contracts")
    op.drop_index(
        op.f("ix_arbitrum_sepolia_contracts_transaction_hash"),
        table_name="arbitrum_sepolia_contracts",
    )
    op.drop_index(
        op.f("ix_arbitrum_sepolia_contracts_name"),
        table_name="arbitrum_sepolia_contracts",
    )
    op.drop_index(
        op.f("ix_arbitrum_sepolia_contracts_deployed_bytecode_hash"),
        table_name="arbitrum_sepolia_contracts",
    )
    op.drop_table("arbitrum_sepolia_contracts")
    op.drop_index(
        op.f("ix_arbitrum_one_contracts_transaction_hash"),
        table_name="arbitrum_one_contracts",
    )
    op.drop_index(
        op.f("ix_arbitrum_one_contracts_name"), table_name="arbitrum_one_contracts"
    )
    op.drop_index(
        op.f("ix_arbitrum_one_contracts_deployed_bytecode_hash"),
        table_name="arbitrum_one_contracts",
    )
    op.drop_table("arbitrum_one_contracts")
    op.drop_index(op.f("ix_bytecode_storage_hash"), table_name="bytecode_storage")
    op.drop_table("bytecode_storage")
    # ### end Alembic commands ###
