"""Doris warehouse migration — telegram_channels table.

Creates the ``telegram_channels`` warehouse table for analytics JOINs.
Enables human-readable channel titles in pipeline dashboards.
"""

from __future__ import annotations

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


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

        Migration(
            version="telegram_channels_doris_0005",
            description="Create telegram_channels warehouse table for analytics JOINs",
            dialect="doris",
            up=(
                MigrationBuilder("telegram_channels", dialect="doris")
                .uuid("id", nullable=False)
                .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)
                .uuid("account_id", nullable=True)
                .timestamp("assigned_at", 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()
            ),
            down=MigrationBuilder("telegram_channels", dialect="doris").drop_table(),
        ),

    ]
