"""Phase 11.10 — analytics and AI content hooks."""
from alembic import op

from app.core.database import Base
import app.models  # noqa: F401

revision = "0011_phase_1110_analytics"
down_revision = "0010_phase_119_consumer_widgets"
branch_labels = None
depends_on = None


def upgrade():
    Base.metadata.create_all(bind=op.get_bind())


def downgrade():
    bind = op.get_bind()
    for table in (
        "experience_ai_content_dispatches",
        "experience_ai_content_hook_registrations",
        "experience_analytics_snapshots",
        "experience_analytics_report_definitions",
    ):
        if table in Base.metadata.tables:
            Base.metadata.tables[table].drop(bind=bind, checkfirst=True)
