"""iphone fields: products.is_iphone + product_items.color/battery_pct

Revision ID: a8c3f1e22a04
Revises: 6574b8389e05
Create Date: 2026-05-12 10:30:00.000000

"""
from alembic import op
import sqlalchemy as sa


revision = 'a8c3f1e22a04'
down_revision = '6574b8389e05'
branch_labels = None
depends_on = None


def upgrade():
    with op.batch_alter_table('products', schema=None) as batch_op:
        batch_op.add_column(
            sa.Column(
                'is_iphone', sa.Boolean(), nullable=False, server_default=sa.false(),
            )
        )
        batch_op.create_index('ix_products_is_iphone', ['is_iphone'])

    with op.batch_alter_table('product_items', schema=None) as batch_op:
        batch_op.add_column(sa.Column('color', sa.String(length=40), nullable=True))
        batch_op.add_column(sa.Column('battery_pct', sa.SmallInteger(), nullable=True))
        batch_op.create_index('ix_product_items_color', ['color'])
        batch_op.create_index('ix_product_items_battery_pct', ['battery_pct'])


def downgrade():
    with op.batch_alter_table('product_items', schema=None) as batch_op:
        batch_op.drop_index('ix_product_items_battery_pct')
        batch_op.drop_index('ix_product_items_color')
        batch_op.drop_column('battery_pct')
        batch_op.drop_column('color')

    with op.batch_alter_table('products', schema=None) as batch_op:
        batch_op.drop_index('ix_products_is_iphone')
        batch_op.drop_column('is_iphone')
