"""Phase 11.3 — Theme & Layout Engine schema."""
from alembic import op
from app.core.database import Base
import app.models  # noqa: F401

revision = "0004_phase_113_themes_layouts"
down_revision = "0003_phase_112_components"
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_page_layout_bindings",
        "experience_site_theme_bindings",
        "experience_layout_versions",
        "experience_theme_versions",
        "experience_layouts",
        "experience_themes",
    ):
        if table in Base.metadata.tables:
            Base.metadata.tables[table].drop(bind=bind, checkfirst=True)
