"""Create ``codal_publishers`` table for codal-parser publisher discovery.  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_postgres_migrations() -> list[Migration]:
    return [
        Migration(
            version="codal_publishers_0001",
            description="Create codal_publishers table for codal.ir publisher info (name + namad)",
            up=(
                MigrationBuilder("codal_publishers")
                .bigint("publisher_id", primary_key=True, nullable=False)
                .text("url", nullable=False)
                .text("name", nullable=True)
                .text("namad", nullable=True)
                .timestamp("created_at", nullable=True, default="now()")
                .timestamp("updated_at", nullable=True, default="now()")
                .index(["namad"])
                .create_table()
            ),
            down=MigrationBuilder("codal_publishers").drop_table(),
        ),
    ]
