"""add_review_created_at_and_report_details

Revision ID: b16ef2228130
Revises: a526deda28e0
Create Date: 2025-12-03 16:15:16.644205

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel


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


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('report', schema=None) as batch_op:
        batch_op.add_column(sa.Column('entity_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False))
        batch_op.add_column(sa.Column('entity_id', sa.Integer(), nullable=False))
        batch_op.add_column(sa.Column('details', sqlmodel.sql.sqltypes.AutoString(), nullable=False))
        batch_op.drop_index(batch_op.f('ix_report_target_id'))
        batch_op.drop_index(batch_op.f('ix_report_target_type'))
        batch_op.create_index(batch_op.f('ix_report_entity_id'), ['entity_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_report_entity_type'), ['entity_type'], unique=False)
        batch_op.drop_column('target_type')
        batch_op.drop_column('target_id')

    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('report', schema=None) as batch_op:
        batch_op.add_column(sa.Column('target_id', sa.INTEGER(), nullable=False))
        batch_op.add_column(sa.Column('target_type', sa.VARCHAR(), nullable=False))
        batch_op.drop_index(batch_op.f('ix_report_entity_type'))
        batch_op.drop_index(batch_op.f('ix_report_entity_id'))
        batch_op.create_index(batch_op.f('ix_report_target_type'), ['target_type'], unique=False)
        batch_op.create_index(batch_op.f('ix_report_target_id'), ['target_id'], unique=False)
        batch_op.drop_column('details')
        batch_op.drop_column('entity_id')
        batch_op.drop_column('entity_type')

    # ### end Alembic commands ###
