"""tasks.deleted_at 列(任务软删除).

Revision ID: 0010
Revises: 0009
Create Date: 2026-06-17

给 tasks 加 deleted_at 列(可空,默认 NULL=未删)。DELETE /v1/tasks/{id} 从硬删
改为软删(置 deleted_at=now()),列表查询过滤 deleted_at IS NULL;新增
POST /v1/tasks/{id}/restore 恢复。软删后 messages / usage_events(原 CASCADE 不再触发)
及工作目录文件全部保留,留作训练语料并支持恢复。

只加列、不动现有数据;历史行 deleted_at 默认 NULL,自动视为"未删"。
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op


revision: str = "0010"
down_revision: Union[str, None] = "0009"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column(
        "tasks",
        sa.Column("deleted_at", sa.DateTime(timezone=True), nullable=True),
    )


def downgrade() -> None:
    op.drop_column("tasks", "deleted_at")
