"""Phase 9.6 — Training Management schema."""
from alembic import op
import sqlalchemy as sa
from app.core.database import Base
import app.models  # noqa: F401

revision = "0007_phase_96_training"
down_revision = "0006_phase_95_attendance"
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 (
        "body_compositions",
        "performance_records",
        "assessments",
        "nutrition_plans",
        "progress_records",
        "measurements",
        "training_goals",
        "workout_assignments",
        "workout_plans",
        "exercises",
        "training_programs",
    ):
        if sa.inspect(bind).has_table(table):
            op.drop_table(table)
