"""PostgreSQL migration: add raw_url_id column to web_parsed_pages.

Stores the ``id`` of the source ``web_html_raw`` row that was parsed
to produce this parsed page.  No FK constraint, no index — just a
plain optional reference for traceability.

Revision ID: 0029
"""
from __future__ import annotations

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

VERSION = "0029"


def get_postgres_migrations() -> list[Migration]:
    return [
        Migration(
            version="parsed_page_raw_url_id_0001",
            description="Add raw_url_id column to web_parsed_pages",
            dialect="postgresql",
            up=(
                MigrationBuilder("web_parsed_pages")
                .add_column("raw_url_id", "TEXT", nullable=True)
                .alter_table()
            ),
            down=(
                MigrationBuilder("web_parsed_pages")
                .drop_column("raw_url_id")
                .alter_table()
            ),
        ),
    ]
