"""Add content_hash to source_videos for duplicate detection.

Revision ID: 005_content_hash
Revises: 004_pipeline_events
"""
from alembic import op
import sqlalchemy as sa

revision = "005_content_hash"
down_revision = "004_pipeline_events"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column(
        "source_videos",
        sa.Column("content_hash", sa.String(64), nullable=True),
    )
    op.create_index(
        "ix_source_videos_content_hash",
        "source_videos",
        ["content_hash"],
    )


def downgrade() -> None:
    op.drop_index("ix_source_videos_content_hash")
    op.drop_column("source_videos", "content_hash")
