"""Create ``codal_publisher_messages`` table.  Revision ID: 0024

Stores supervisor messages from ``/fa/publisher/<id>/message``.
"""

from __future__ import annotations

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

VERSION = "0024"


def get_postgres_migrations() -> list[Migration]:
    return [
        Migration(
            version="codal_publisher_messages_0001",
            description="Create codal_publisher_messages table for supervisor messages",
            up=(
                MigrationBuilder("codal_publisher_messages")
                .uuid("id", primary_key=True, nullable=False)
                .bigint("publisher_id", nullable=False)
                .text("title", nullable=True)
                .text("message_date", nullable=True)
                .text("message_time", nullable=True)
                .text("description", nullable=True)
                .timestamp("created_at", nullable=True, default="now()")
                .timestamp("updated_at", nullable=True, default="now()")
                .index(["publisher_id"])
                .create_table()
            ),
            down=MigrationBuilder("codal_publisher_messages").drop_table(),
        ),
    ]
