"""Phase 11.2 — Component Library & Versioning schema."""
from alembic import op
from app.core.database import Base
import app.models  # noqa: F401

revision = "0003_phase_112_components"
down_revision = "0002_phase_111_sites_pages"
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_component_placements",
        "experience_component_versions",
        "experience_components",
    ):
        if table in Base.metadata.tables:
            Base.metadata.tables[table].drop(bind=bind, checkfirst=True)
