diff --git a/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/5ce23893771f_add_deployed_by_column.py b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/5ce23893771f_add_deployed_by_column.py new file mode 100644 index 00000000..9259a1b4 --- /dev/null +++ b/moonstreamdb-v3/moonstreamdbv3/alembic_indexes/versions/5ce23893771f_add_deployed_by_column.py @@ -0,0 +1,253 @@ +"""Add deployed by column + +Revision ID: 5ce23893771f +Revises: 82ff1541f4b4 +Create Date: 2024-11-07 14:03:31.833443 + +""" + +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = "5ce23893771f" +down_revision: Union[str, None] = "82ff1541f4b4" +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.add_column( + "arbitrum_one_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_arbitrum_one_contracts_deployed_by"), + "arbitrum_one_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "arbitrum_sepolia_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_arbitrum_sepolia_contracts_deployed_by"), + "arbitrum_sepolia_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "b3_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_b3_contracts_deployed_by"), + "b3_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "b3_sepolia_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_b3_sepolia_contracts_deployed_by"), + "b3_sepolia_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "ethereum_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_ethereum_contracts_deployed_by"), + "ethereum_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "game7_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_game7_contracts_deployed_by"), + "game7_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "game7_orbit_arbitrum_sepolia_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_game7_orbit_arbitrum_sepolia_contracts_deployed_by"), + "game7_orbit_arbitrum_sepolia_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "game7_testnet_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_game7_testnet_contracts_deployed_by"), + "game7_testnet_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "imx_zkevm_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_imx_zkevm_contracts_deployed_by"), + "imx_zkevm_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "imx_zkevm_sepolia_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_imx_zkevm_sepolia_contracts_deployed_by"), + "imx_zkevm_sepolia_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "mantle_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_mantle_contracts_deployed_by"), + "mantle_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "mantle_sepolia_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_mantle_sepolia_contracts_deployed_by"), + "mantle_sepolia_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "polygon_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_polygon_contracts_deployed_by"), + "polygon_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "sepolia_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_sepolia_contracts_deployed_by"), + "sepolia_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "xai_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_xai_contracts_deployed_by"), + "xai_contracts", + ["deployed_by"], + unique=False, + ) + op.add_column( + "xai_sepolia_contracts", + sa.Column("deployed_by", sa.LargeBinary(length=20), nullable=False), + ) + op.create_index( + op.f("ix_xai_sepolia_contracts_deployed_by"), + "xai_sepolia_contracts", + ["deployed_by"], + unique=False, + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index( + op.f("ix_xai_sepolia_contracts_deployed_by"), table_name="xai_sepolia_contracts" + ) + op.drop_column("xai_sepolia_contracts", "deployed_by") + op.drop_index(op.f("ix_xai_contracts_deployed_by"), table_name="xai_contracts") + op.drop_column("xai_contracts", "deployed_by") + op.drop_index( + op.f("ix_sepolia_contracts_deployed_by"), table_name="sepolia_contracts" + ) + op.drop_column("sepolia_contracts", "deployed_by") + op.drop_index( + op.f("ix_polygon_contracts_deployed_by"), table_name="polygon_contracts" + ) + op.drop_column("polygon_contracts", "deployed_by") + op.drop_index( + op.f("ix_mantle_sepolia_contracts_deployed_by"), + table_name="mantle_sepolia_contracts", + ) + op.drop_column("mantle_sepolia_contracts", "deployed_by") + op.drop_index( + op.f("ix_mantle_contracts_deployed_by"), table_name="mantle_contracts" + ) + op.drop_column("mantle_contracts", "deployed_by") + op.drop_index( + op.f("ix_imx_zkevm_sepolia_contracts_deployed_by"), + table_name="imx_zkevm_sepolia_contracts", + ) + op.drop_column("imx_zkevm_sepolia_contracts", "deployed_by") + op.drop_index( + op.f("ix_imx_zkevm_contracts_deployed_by"), table_name="imx_zkevm_contracts" + ) + op.drop_column("imx_zkevm_contracts", "deployed_by") + op.drop_index( + op.f("ix_game7_testnet_contracts_deployed_by"), + table_name="game7_testnet_contracts", + ) + op.drop_column("game7_testnet_contracts", "deployed_by") + op.drop_index( + op.f("ix_game7_orbit_arbitrum_sepolia_contracts_deployed_by"), + table_name="game7_orbit_arbitrum_sepolia_contracts", + ) + op.drop_column("game7_orbit_arbitrum_sepolia_contracts", "deployed_by") + op.drop_index(op.f("ix_game7_contracts_deployed_by"), table_name="game7_contracts") + op.drop_column("game7_contracts", "deployed_by") + op.drop_index( + op.f("ix_ethereum_contracts_deployed_by"), table_name="ethereum_contracts" + ) + op.drop_column("ethereum_contracts", "deployed_by") + op.drop_index( + op.f("ix_b3_sepolia_contracts_deployed_by"), table_name="b3_sepolia_contracts" + ) + op.drop_column("b3_sepolia_contracts", "deployed_by") + op.drop_index(op.f("ix_b3_contracts_deployed_by"), table_name="b3_contracts") + op.drop_column("b3_contracts", "deployed_by") + op.drop_index( + op.f("ix_arbitrum_sepolia_contracts_deployed_by"), + table_name="arbitrum_sepolia_contracts", + ) + op.drop_column("arbitrum_sepolia_contracts", "deployed_by") + op.drop_index( + op.f("ix_arbitrum_one_contracts_deployed_by"), + table_name="arbitrum_one_contracts", + ) + op.drop_column("arbitrum_one_contracts", "deployed_by") + # ### end Alembic commands ### diff --git a/moonstreamdb-v3/moonstreamdbv3/models_indexes.py b/moonstreamdb-v3/moonstreamdbv3/models_indexes.py index d8878a05..ff1bf5a6 100644 --- a/moonstreamdb-v3/moonstreamdbv3/models_indexes.py +++ b/moonstreamdb-v3/moonstreamdbv3/models_indexes.py @@ -106,6 +106,7 @@ class EvmBasedReorgs(Base): class evmBasedContracts(Base): __abstract__ = True address = Column(LargeBinary(length=20), primary_key=True, nullable=False) + deployed_by = Column(LargeBinary(length=20), nullable=False, index=True) deployed_bytecode = Column(Text, nullable=False) deployed_bytecode_hash = Column( VARCHAR(32), nullable=False, index=True diff --git a/moonstreamdb-v3/moonstreamdbv3/version.txt b/moonstreamdb-v3/moonstreamdbv3/version.txt index 6e8bf73a..17e51c38 100644 --- a/moonstreamdb-v3/moonstreamdbv3/version.txt +++ b/moonstreamdb-v3/moonstreamdbv3/version.txt @@ -1 +1 @@ -0.1.0 +0.1.1