"""Add is_regex column to dictionary_entries

Revision ID: b2c3d4e5f6a7
Revises: a1b2c3d4e5f6
Create Date: 2026-06-04

Add regex pattern support to terminology dictionary entries.
When is_regex=True, source_term is treated as a regex pattern
instead of a literal substring for matching and enforcement.
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = "b2c3d4e5f6a7"
down_revision: Union[str, None] = "a1b2c3d4e5f6"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column(
        "dictionary_entries",
        sa.Column(
            "is_regex",
            sa.Boolean(),
            nullable=False,
            server_default=sa.text("false"),
            comment="Whether source_term is a regex pattern",
        ),
    )


def downgrade() -> None:
    op.drop_column("dictionary_entries", "is_regex")
