"""Add featured_until to listings (Phase 2B: featured expiration)

Records when a listing's 7-day featured period ends. A listing is only treated
as *currently* featured while ``featured_until`` is in the future.

Revision ID: f9a2c3d4e5b6
Revises: e8f1a2b3c4d5
Create Date: 2026-07-04 00:00:00.000000

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "f9a2c3d4e5b6"
down_revision = "e8f1a2b3c4d5"
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_until", sa.DateTime(timezone=True), nullable=True))
        batch_op.create_index(batch_op.f("ix_listings_featured_until"), ["featured_until"], 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_until"))
        batch_op.drop_column("featured_until")
