"""Add ``version`` and ``statement_version`` columns to ``codal_media`` table.

Revision ID: 0028
"""
from __future__ import annotations

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

VERSION = "0028"


def get_postgres_migrations() -> list[Migration]:
    return [
        Migration(
            version="codal_media_version_0001",
            description="Add version and statement_version to codal_media",
            up=(
                MigrationBuilder("codal_media")
                .add_column("version", "INTEGER", nullable=True, default=1)
                .add_column("statement_version", "INTEGER", nullable=True)
                .alter_table()
            ),
            down=(
                MigrationBuilder("codal_media")
                .drop_column("statement_version")
                .drop_column("version")
                .alter_table()
            ),
        ),
    ]
