"""Add ``version`` column to ``web_media`` Doris warehouse table.

- ``version``: monotonically increasing version counter per source_url (INT, default 1)

Together with ``content_hash`` this enables content-change detection
and versioned history — when content is unchanged on re-download, no
new warehouse row is inserted.

Revision ID: 0017
"""
from __future__ import annotations

from repo_core.migrations.builder import MigrationBuilder
from repo_core.migrations.runner import Migration

VERSION = "0017"


def get_doris_migrations() -> list[Migration]:
    return [
        Migration(
            version="web_media_doris_version_0001",
            description="Add version column to web_media warehouse table",
            dialect="doris",
            up=(
                MigrationBuilder("web_media", dialect="doris")
                .add_column("version", "INT", nullable=True, default=1)
                .alter_table()
            ),
            down=(
                MigrationBuilder("web_media", dialect="doris")
                .drop_column("version")
                .alter_table()
            ),
        ),
    ]
