"""Phase 11.4 — Template System schema."""
from alembic import op
from app.core.database import Base
import app.models  # noqa: F401

revision = "0005_phase_114_templates"
down_revision = "0004_phase_113_themes_layouts"
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_template_instantiations",
        "experience_template_versions",
        "experience_templates",
    ):
        if table in Base.metadata.tables:
            Base.metadata.tables[table].drop(bind=bind, checkfirst=True)
