"""Add HTTP ``etag`` column to ``web_media`` for audit of source-server ETag headers.

Revision ID: 0020
"""
from __future__ import annotations

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

VERSION = "0020"


def get_postgres_migrations() -> list[Migration]:
    return [
        Migration(
            version="web_media_etag_0001",
            description="Add etag column to web_media",
            up=(
                MigrationBuilder("web_media")
                .add_column("etag", "TEXT", nullable=True)
                .add_index(["etag"])
                .alter_table()
            ),
            down=(
                MigrationBuilder("web_media")
                .drop_column("etag")
                .alter_table()
            ),
        ),
    ]
