"""Add tone/ending_type/narrative_pov to projects (灵感④ 立项书级常量).

三列均 Text nullable（与既有 genre/structure 一致，无 CHECK；枚举约束留前端预设），
nullable 免 backfill（旧项目留 NULL，assemble/前端优雅降级）。

Revision ID: e5f6a7b8c9d0
Revises: 8c1d2e3f4a5b
Create Date: 2026-07-06 00:00:00.000000
"""

from __future__ import annotations

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op

revision: str = "e5f6a7b8c9d0"
down_revision: str | None = "8c1d2e3f4a5b"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    op.add_column("projects", sa.Column("tone", sa.Text(), nullable=True))
    op.add_column("projects", sa.Column("ending_type", sa.Text(), nullable=True))
    op.add_column("projects", sa.Column("narrative_pov", sa.Text(), nullable=True))


def downgrade() -> None:
    op.drop_column("projects", "narrative_pov")
    op.drop_column("projects", "ending_type")
    op.drop_column("projects", "tone")
