"""Phase 11.9 — consumer connectors, widgets and notify dispatches."""
from alembic import op

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

revision = "0010_phase_119_consumer_widgets"
down_revision = "0009_phase_118_bundles_toggles"
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_notify_dispatches",
        "experience_widget_instances",
        "experience_widget_definitions",
        "experience_consumer_connector_dispatches",
        "experience_consumer_connector_registrations",
    ):
        if table in Base.metadata.tables:
            Base.metadata.tables[table].drop(bind=bind, checkfirst=True)
