"""add_review_targets

Revision ID: 6659cb1e0ca5
Revises: 83e6fd46fa2b
Create Date: 2025-12-03 13:05:43.037872

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '6659cb1e0ca5'
down_revision: Union[str, Sequence[str], None] = '83e6fd46fa2b'
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('review', schema=None) as batch_op:
        batch_op.add_column(sa.Column('performance_id', sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column('tour_id', sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column('year', sa.Integer(), nullable=True))
        batch_op.create_foreign_key('fk_review_tour_id', 'tour', ['tour_id'], ['id'])
        batch_op.create_foreign_key('fk_review_performance_id', 'performance', ['performance_id'], ['id'])

    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('review', schema=None) as batch_op:
        batch_op.add_column(sa.Column('created_at', sa.DATETIME(), nullable=False))
        batch_op.drop_constraint(None, type_='foreignkey')
        batch_op.drop_constraint(None, type_='foreignkey')
        batch_op.drop_column('year')
        batch_op.drop_column('tour_id')
        batch_op.drop_column('performance_id')

    # ### end Alembic commands ###
