"""Phase 11.6 — Forms, Surveys & Appointments schema."""
from alembic import op
from app.core.database import Base
import app.models  # noqa: F401

revision = "0007_phase_116_forms_appts"
down_revision = "0006_phase_115_loc_media"
branch_labels = None
depends_on = None


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


def downgrade():
    bind = op.get_bind()
    for table in (
        "experience_appointment_booking_refs",
        "experience_appointment_pages",
        "experience_survey_responses",
        "experience_surveys",
        "experience_form_submissions",
        "experience_forms",
    ):
        if table in Base.metadata.tables:
            Base.metadata.tables[table].drop(bind=bind, checkfirst=True)
