"""series chapter stated_part: operator-facing Part N label (FC-6.4)

Revision ID: 0042
Revises: 0041
Create Date: 2026-06-07

A chapter's positional chapter_number is auto-managed (rewritten 1..N on
reorder/delete), so it can't double as the installment number the operator wants
to type (e.g. a series authored from a post that is Part 2). Add a nullable
stated_part alongside it — the same split as series_page.page_number (order) vs
series_page.stated_page (printed number). Nullable; the UI falls back to
chapter_number when unset.
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = "0042"
down_revision: Union[str, None] = "0041"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column(
        "series_chapter", sa.Column("stated_part", sa.Integer, nullable=True)
    )


def downgrade() -> None:
    op.drop_column("series_chapter", "stated_part")
