"""Add crawl_site.schedule_cron — site-level cron default.

Revision ID: 0006_add_site_schedule_cron
Revises: 0005_site_crawl_plan
Create Date: 2026-04-27

Schedule resolution chain becomes:

    crawl_target.schedule_cron      (per-target override; UI not yet exposed)
        ↓
    yaml column.schedule            (per-column block in yaml)
        ↓
    yaml default_column.schedule    (per-yaml-site, added 2026-04-27)
        ↓
    crawl_site.schedule_cron        (THIS — per-DB-site, applies to gkmlpt
                                      adapter sites that have no yaml)
        ↓
    DEFAULT_SCHEDULE = '0 2 * * *'  (codebase fallback)

Nullable so all existing rows keep DEFAULT_SCHEDULE behavior on upgrade;
operators opt in by setting this from the site editor.
"""
from alembic import op
import sqlalchemy as sa

revision = "0006_add_site_schedule_cron"
down_revision = "0005_site_crawl_plan"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column("crawl_site", sa.Column("schedule_cron", sa.String(length=100), nullable=True))


def downgrade() -> None:
    op.drop_column("crawl_site", "schedule_cron")
