"""Drop unused leased_until and leased_by columns from telegram_accounts.

These columns were never written to — worker-to-account assignment is
tracked exclusively through Redis (telemetry heartbeat/ping system).
The API response has always hardcoded them to ``None``.
"""

from __future__ import annotations

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

VERSION = "0006"


def get_postgres_migrations() -> list[Migration]:
    """Return ordered PostgreSQL migrations."""

    return [
        Migration(
            version="tg_account_drop_leased_columns",
            description=(
                "Drop unused leased_until, leased_by columns "
                "from telegram_accounts — worker assignment uses Redis"
            ),
            up=(
                MigrationBuilder("telegram_accounts")
                .drop_column("leased_until")
                .drop_column("leased_by")
                .alter_table()
            ),
            down=(
                MigrationBuilder("telegram_accounts")
                .add_column("leased_until", "TIMESTAMP WITH TIME ZONE", nullable=True)
                .add_column("leased_by", "TEXT", nullable=True)
                .alter_table()
            ),
        ),
    ]
