"""featured products table

Revision ID: c1a8d2f51b22
Revises: b9d4f2c33b15
Create Date: 2026-05-19 12:00:00.000000

"""
from alembic import op
import sqlalchemy as sa


revision = 'c1a8d2f51b22'
down_revision = 'b9d4f2c33b15'
branch_labels = None
depends_on = None


def upgrade():
    op.create_table(
        'featured_products',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('product_id', sa.Integer(), nullable=False),
        sa.Column('position', sa.Integer(), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(['product_id'], ['products.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
    )
    with op.batch_alter_table('featured_products', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_featured_products_product_id'), ['product_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_featured_products_position'), ['position'], unique=True)


def downgrade():
    with op.batch_alter_table('featured_products', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_featured_products_position'))
        batch_op.drop_index(batch_op.f('ix_featured_products_product_id'))
    op.drop_table('featured_products')
