"""Create ``codal_publisher_details`` table.  Revision ID: 0021

Extracts detailed company info from the publisher profile page
(``/fa/publisher/<id>/``) — CEO, CFO, auditor, capital, ISIC/ISIN, etc.
"""

from __future__ import annotations

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

VERSION = "0021"


def get_postgres_migrations() -> list[Migration]:
    return [
        Migration(
            version="codal_publisher_details_0001",
            description="Create codal_publisher_details table for detailed company info",
            up=(
                MigrationBuilder("codal_publisher_details")
                .bigint("publisher_id", primary_key=True, nullable=False)
                .text("ceo", nullable=True)
                .text("cfo", nullable=True)
                .text("activity_field", nullable=True)
                .text("auditor", nullable=True)
                .text("alt_auditor", nullable=True)
                .text("company_type", nullable=True)
                .text("acceptance_type", nullable=True)
                .text("nature", nullable=True)
                .text("registered_capital", nullable=True)
                .text("unregistered_capital", nullable=True)
                .text("national_id", nullable=True)
                .text("isic", nullable=True)
                .text("isin", nullable=True)
                .text("fiscal_year_end", nullable=True)
                .text("seo_deposit_id", nullable=True)
                .text("industry_group", nullable=True)
                .text("stock_status", nullable=True)
                .timestamp("created_at", nullable=True, default="now()")
                .timestamp("updated_at", nullable=True, default="now()")
                .create_table()
            ),
            down=MigrationBuilder("codal_publisher_details").drop_table(),
        ),
    ]
