"""add_remediation_fields

Revision ID: b007remediation
Revises: b006notifications
Create Date: 2026-02-09 11:30:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import UUID


# revision identifiers, used by Alembic.
revision: str = 'b007remediation'
down_revision: Union[str, Sequence[str], None] = 'b006notifications'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Add remediation fields to tests and test_templates."""
    # Tests — remediation fields
    op.add_column('tests', sa.Column('remediation_steps', sa.Text(), nullable=True))
    op.add_column('tests', sa.Column('remediation_status', sa.String(), nullable=True))
    op.add_column('tests', sa.Column('remediation_assignee', UUID(as_uuid=True), nullable=True))
    op.create_foreign_key(
        'fk_tests_remediation_assignee',
        'tests', 'users',
        ['remediation_assignee'], ['id'],
    )

    # TestTemplates — suggested_remediation
    op.add_column('test_templates', sa.Column('suggested_remediation', sa.Text(), nullable=True))


def downgrade() -> None:
    """Remove remediation fields."""
    op.drop_column('test_templates', 'suggested_remediation')
    op.drop_constraint('fk_tests_remediation_assignee', 'tests', type_='foreignkey')
    op.drop_column('tests', 'remediation_assignee')
    op.drop_column('tests', 'remediation_status')
    op.drop_column('tests', 'remediation_steps')
