"""Doris migration: drop telegram_channels warehouse table.

The ``telegram_channels`` table in Doris was used only to resolve
numeric ``peer_id`` → human-readable ``title``/``username`` in
analytics LEFT JOINs.  Channel metadata is now resolved at the
service layer via a PostgreSQL batch lookup, making this warehouse
table unnecessary.
"""

from __future__ import annotations

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

VERSION = "0006"


def get_doris_migrations() -> list[Migration]:
    """Return ordered Doris migrations."""
    return [

        Migration(
            version="telegram_channels_drop_0006",
            description=(
                "Drop telegram_channels warehouse table — channel metadata "
                "now resolved from PostgreSQL at the service layer"
            ),
            up=(
                MigrationBuilder("telegram_channels", dialect="doris")
                .drop_table()
            ),
            down=(
                MigrationBuilder("telegram_channels", dialect="doris")
                .bigint("channel_id", nullable=False)
                .varchar("title", 500, nullable=False)
                .varchar("username", 200, nullable=True)
                .varchar("kind", 50, nullable=True, default="channel")
                .bigint("member_count", nullable=True)
                .text("description", nullable=True)
                .timestamp("created_at", nullable=True)
                .timestamp("updated_at", nullable=True)
                .doris_unique_key(["channel_id"])
                .doris_distributed_by("channel_id", buckets=10)
                .create_table()
            ),
        ),

    ]
