"""rulebook always_on flag

Revision ID: 0058
Revises: 0057
Create Date: 2026-06-01

Adds a boolean `always_on` to the `rulebooks` table. Rules from rulebooks
flagged always_on are loaded at session start by the new
`list_always_on_rules` MCP tool — they apply regardless of which project
(if any) is in scope. Seeds the FabledSword family rulebook to always_on
because that's the cross-project standards rulebook by design.
"""
from alembic import op
import sqlalchemy as sa


revision = "0058"
down_revision = "0057"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column(
        "rulebooks",
        sa.Column(
            "always_on",
            sa.Boolean(),
            nullable=False,
            server_default=sa.text("false"),
        ),
    )
    op.execute(
        "UPDATE rulebooks SET always_on = TRUE WHERE title = 'FabledSword family'"
    )


def downgrade() -> None:
    op.drop_column("rulebooks", "always_on")
