"""Add Game7 mainnet indexes

Revision ID: c1bc596631f9
Revises: 6807bdf6f417
Create Date: 2024-10-14 16:10:27.757094

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'c1bc596631f9'
down_revision: Union[str, None] = '6807bdf6f417'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('game7_blocks',
    sa.Column('l1_block_number', sa.BigInteger(), nullable=False),
    sa.Column('block_number', sa.BigInteger(), nullable=False),
    sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
    sa.Column('block_timestamp', sa.BigInteger(), nullable=False),
    sa.Column('parent_hash', sa.VARCHAR(length=256), nullable=False),
    sa.Column('row_id', sa.BigInteger(), nullable=False),
    sa.Column('path', sa.Text(), nullable=False),
    sa.Column('transactions_indexed_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('logs_indexed_at', sa.DateTime(timezone=True), nullable=True),
    sa.Column('indexed_at', sa.DateTime(timezone=True), server_default=sa.text("TIMEZONE('utc', statement_timestamp())"), nullable=False),
    sa.PrimaryKeyConstraint('block_number', name=op.f('pk_game7_blocks'))
    )
    op.create_index(op.f('ix_game7_blocks_block_number'), 'game7_blocks', ['block_number'], unique=False)
    op.create_index(op.f('ix_game7_blocks_block_timestamp'), 'game7_blocks', ['block_timestamp'], unique=False)
    op.create_table('game7_reorgs',
    sa.Column('id', sa.UUID(), nullable=False),
    sa.Column('block_number', sa.BigInteger(), nullable=False),
    sa.Column('block_hash', sa.VARCHAR(length=256), nullable=False),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_game7_reorgs'))
    )
    op.create_index(op.f('ix_game7_reorgs_block_hash'), 'game7_reorgs', ['block_hash'], unique=False)
    op.create_index(op.f('ix_game7_reorgs_block_number'), 'game7_reorgs', ['block_number'], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_game7_reorgs_block_number'), table_name='game7_reorgs')
    op.drop_index(op.f('ix_game7_reorgs_block_hash'), table_name='game7_reorgs')
    op.drop_table('game7_reorgs')
    op.drop_index(op.f('ix_game7_blocks_block_timestamp'), table_name='game7_blocks')
    op.drop_index(op.f('ix_game7_blocks_block_number'), table_name='game7_blocks')
    op.drop_table('game7_blocks')
    # ### end Alembic commands ###
