"""task canonical record id (STATE-WP-0083-T06)

Every work-record type carries a stable canonical identifier except tasks. A
task row holds `id, workplan_id, title, status, priority` — nothing connecting it
to `CUST-WP-0067-T01` in the file it came from.

The consequence is that a file task and a hub task can only be matched by title,
so a renamed heading looks like one task disappearing and another appearing. That
is why the forge-derived reset deliberately refuses to touch tasks of existing
workplans: destroying and recreating a record because someone edited a heading is
not an acceptable failure mode.

Nullable on purpose. Existing rows have no canonical id and cannot be given one
by this migration — only the repository files know the mapping, and backfilling
from them is a separate, reversible step.

Revision ID: e2b3c4d5f6a7
Revises: d1a2b3c4e5f6
"""
from alembic import op
import sqlalchemy as sa

revision = "e2b3c4d5f6a7"
down_revision = "d1a2b3c4e5f6"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column("tasks", sa.Column("record_id", sa.String(length=120), nullable=True))
    op.create_index("ix_tasks_record_id", "tasks", ["record_id"])


def downgrade() -> None:
    op.drop_index("ix_tasks_record_id", table_name="tasks")
    op.drop_column("tasks", "record_id")
