"""Create tweets table

Revision ID: 0002
Revises: 0001
Create Date: 2026-01-17 00:00:00.000000

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '0002'
down_revision = '0001'
branch_labels = None
depends_on = None


def upgrade() -> None:
    """Create tweets table."""
    op.create_table(
        'tweets',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('tweet_id', sa.String(length=255), nullable=False),
        sa.Column('text', sa.String(length=1000), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('retweet_count', sa.Integer(), nullable=True),
        sa.Column('like_count', sa.Integer(), nullable=True),
        sa.Column('match_id', sa.Integer(), nullable=True),
        sa.Column('source', sa.String(length=50), nullable=True),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_tweets_id'), 'tweets', ['id'], unique=False)
    op.create_index(op.f('ix_tweets_tweet_id'), 'tweets', ['tweet_id'], unique=True)
    op.create_index(op.f('ix_tweets_created_at'), 'tweets', ['created_at'], unique=False)
    op.create_index(op.f('ix_tweets_match_id'), 'tweets', ['match_id'], unique=False)
    op.create_index('idx_tweets_match_id_source', 'tweets', ['match_id', 'source'], unique=False)


def downgrade() -> None:
    """Drop tweets table."""
    op.drop_index('idx_tweets_match_id_source', table_name='tweets')
    op.drop_index(op.f('ix_tweets_match_id'), table_name='tweets')
    op.drop_index(op.f('ix_tweets_created_at'), table_name='tweets')
    op.drop_index(op.f('ix_tweets_tweet_id'), table_name='tweets')
    op.drop_index(op.f('ix_tweets_id'), table_name='tweets')
    op.drop_table('tweets')
