"""Add featured_at to listings (Phase 2B: featured listings)

``is_featured`` already exists on ``listings``; this adds ``featured_at`` to
record when a listing became featured, used to order featured listings
(most-recently-featured first).

Revision ID: e8f1a2b3c4d5
Revises: d7e9b1f4a3c2
Create Date: 2026-07-03 00:00:00.000000

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "e8f1a2b3c4d5"
down_revision = "d7e9b1f4a3c2"
branch_labels = None
depends_on = None


def upgrade():
    with op.batch_alter_table("listings", schema=None) as batch_op:
        batch_op.add_column(sa.Column("featured_at", sa.DateTime(timezone=True), nullable=True))
        batch_op.create_index(batch_op.f("ix_listings_featured_at"), ["featured_at"], unique=False)


def downgrade():
    with op.batch_alter_table("listings", schema=None) as batch_op:
        batch_op.drop_index(batch_op.f("ix_listings_featured_at"))
        batch_op.drop_column("featured_at")
