"""add tactic_ids JSON column to simulations

Revision ID: 0004
Revises: 0003
Create Date: 2026-05-27 00:00:00.000000
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.sql import text

revision = "0004"
down_revision = "0003"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ADD COLUMN is safe on SQLite without batch mode.
    # server_default='[]' satisfies NOT NULL for existing rows.
    op.add_column(
        "simulations",
        sa.Column(
            "tactic_ids",
            sa.JSON(),
            nullable=False,
            server_default=text("'[]'"),
        ),
    )


def downgrade() -> None:
    with op.batch_alter_table("simulations") as batch_op:
        batch_op.drop_column("tactic_ids")
