"""Add listing sold fields (GMV tracking)

Revision ID: 009
Revises: 008
Create Date: 2025-12-15
"""

from alembic import op
import sqlalchemy as sa

revision = '009'
down_revision = '008'
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column('domain_listings', sa.Column('sold_at', sa.DateTime(), nullable=True))
    op.add_column('domain_listings', sa.Column('sold_reason', sa.String(200), nullable=True))
    op.add_column('domain_listings', sa.Column('sold_price', sa.Float(), nullable=True))
    op.add_column('domain_listings', sa.Column('sold_currency', sa.String(3), nullable=True))

    op.create_index('ix_domain_listings_status', 'domain_listings', ['status'], unique=False)


def downgrade() -> None:
    op.drop_index('ix_domain_listings_status', table_name='domain_listings')
    op.drop_column('domain_listings', 'sold_currency')
    op.drop_column('domain_listings', 'sold_price')
    op.drop_column('domain_listings', 'sold_reason')
    op.drop_column('domain_listings', 'sold_at')
