"""Add stream_filepath and waveform_filepath

Revision ID: 003
Revises: 002
Create Date: 2025-12-23

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '003'
down_revision: Union[str, None] = '002'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Add stream_filepath and waveform_filepath columns."""
    # Add stream_filepath column (MP3 128kbps for fast streaming)
    op.add_column('audio_tracks', sa.Column('stream_filepath', sa.String(), nullable=True))

    # Add waveform_filepath column (pre-computed waveform JSON)
    op.add_column('audio_tracks', sa.Column('waveform_filepath', sa.String(), nullable=True))

    # Add index on stream_filepath for faster lookups
    op.create_index('idx_stream_filepath', 'audio_tracks', ['stream_filepath'])


def downgrade() -> None:
    """Remove stream_filepath and waveform_filepath columns."""
    op.drop_index('idx_stream_filepath', table_name='audio_tracks')
    op.drop_column('audio_tracks', 'waveform_filepath')
    op.drop_column('audio_tracks', 'stream_filepath')
