"""Seed the gated daily AI 大脑 narrative job. Revision ID: 480 Revises: 479 """ import uuid import sqlalchemy as sa from alembic import op revision = "480" down_revision = "479" branch_labels = None depends_on = None _JOB = "intelligence.analysis_daily" def upgrade() -> None: bind = op.get_bind() if bind.execute( sa.text("SELECT 1 FROM scheduled_jobs WHERE name = :name LIMIT 1"), {"name": _JOB}, ).scalar(): return bind.execute( sa.text( """ INSERT INTO scheduled_jobs (id, name, display_name, description, handler_key, trigger_type, interval_seconds, cron_expr, timezone, enabled, config, run_count, failure_count, created_at, updated_at) VALUES (:id, :name, :display_name, :description, :name, 'cron', NULL, '35 7 * * *', 'UTC', 1, :config, 0, 0, UTC_TIMESTAMP(), UTC_TIMESTAMP()) """ ), { "id": str(uuid.uuid4()), "name": _JOB, "display_name": "AI 大脑每日跨域简报", "description": ( "在确定性快照生成后按事实 Hash 生成全平台中英双语简报;" "功能开关关闭时安全跳过,不影响快照和平台运行。" ), "config": "{}", }, ) def downgrade() -> None: op.get_bind().execute( sa.text("DELETE FROM scheduled_jobs WHERE name = :name"), {"name": _JOB}, )