""" Seed the database with initial data (exercises, phases, measurement types). Run with: python scripts/seed.py """ import asyncio import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).parent.parent)) from sqlalchemy import select from app.models import async_session from app.models.exercise import Exercise from app.models.workout import Phase from app.models.measurement import MeasurementType EXERCISES = [ ("Bench Press", "chest", "barbell, bench"), ("Incline Dumbbell Press", "chest", "dumbbell, bench"), ("Overhead Press", "shoulders", "barbell"), ("Landmine Press", "shoulders", "landmine"), ("Band Press", "chest", "bands"), ("Lateral Raise", "shoulders", "dumbbell"), ("Tricep Pushdown", "triceps", "cable, bands"), ("Dip", "chest", "dip station"), ("Barbell Row", "back", "barbell"), ("Dumbbell Row", "back", "dumbbell, bench"), ("Lat Pulldown", "back", "cable, bands"), ("Pull-up", "back", "pull-up bar"), ("Face Pull", "shoulders", "cable, bands"), ("YTW", "shoulders", "dumbbell, bands"), ("Bicep Curl", "biceps", "dumbbell"), ("Barbell Squat", "quadriceps", "barbell, squat rack"), ("Goblet Squat", "quadriceps", "dumbbell, kettlebell"), ("Bulgarian Split Squat", "quadriceps", "dumbbell, bench"), ("Hip Thrust", "glutes", "barbell, bench"), ("Step-up", "quadriceps", "dumbbell, bench"), ("Romanian Deadlift", "hamstrings", "barbell"), ("Leg Curl", "hamstrings", "cable, bands"), ("Calf Raise", "calves", "barbell, dumbbell"), ("Deadlift", "back", "barbell"), ("Dead Bug", "core", "bodyweight"), ("Pallof Press", "core", "cable, bands"), ("Plank", "core", "bodyweight"), ("Ab Wheel Rollout", "core", "ab wheel"), ("Russian Twist", "core", "bodyweight, dumbbell"), ("Hanging Knee Raise", "core", "pull-up bar"), ("BikeErg", "cardio", "bikeerg"), ("RowErg", "cardio", "rowerg"), ("Jump Rope", "cardio", "jump rope"), ("Walking", "cardio", "bodyweight"), ("Farmer's Carry", "grip", "dumbbell, kettlebell"), ("Bird Dog", "core", "bodyweight"), ("Glute Bridge", "glutes", "bodyweight"), ("Clamshell", "glutes", "bodyweight, bands"), ("90/90 Stretch", "hips", "bodyweight"), ("Supine Piriformis Stretch", "hips", "bodyweight"), ] PHASES = [ ("Tendon Adaptation", "Phase 1: Return to training after layoff. RPE 6-7, limited ROM, mid-range movements only.", "2026-06-25", None, "Weeks 1-4"), ("Progressive Loading", "Phase 2: Increase load gradually. RPE 7-8, full ROM where tolerated.", None, None, "Weeks 4-8"), ("Strength Building", "Phase 3: Normal training. RPE 8-9, full ROM.", None, None, "Weeks 8+"), ] MEASUREMENT_TYPES = [ ("Weight", "Body weight measurement", "lb", "Weigh yourself first thing in the morning, after using the bathroom, before eating or drinking."), ("Waist", "Waist circumference", "in", "Measure at the narrowest point of your waist, typically just above the belly button."), ("Neck", "Neck circumference", "in", "Measure at the narrowest point, just below the Adam's apple."), ("Chest", "Chest circumference", "in", "Measure at the fullest part of the chest, arms relaxed at sides."), ("Arm", "Upper arm circumference", "in", "Measure at the midpoint between shoulder and elbow, arm relaxed."), ("Thigh", "Thigh circumference", "in", "Measure at the midpoint between hip and knee."), ("Hip", "Hip circumference", "in", "Measure at the widest part of the hips/glutes."), ("Body Fat", "Estimated body fat percentage", "%", "Use calipers or smart scale. Consistent method is more important than absolute accuracy."), ] async def seed(): async with async_session() as session: result = await session.execute(select(Exercise).limit(1)) if result.scalar_one_or_none(): print("Exercises already seeded, skipping.") else: for name, body_part, equipment in EXERCISES: session.add(Exercise(name=name, body_part=body_part, equipment=equipment)) print(f"Seeded {len(EXERCISES)} exercises.") result = await session.execute(select(Phase).limit(1)) if result.scalar_one_or_none(): print("Phases already seeded, skipping.") else: for name, desc, start, end, notes in PHASES: session.add(Phase(name=name, description=desc, start_date=start, end_date=end, notes=notes)) print(f"Seeded {len(PHASES)} phases.") result = await session.execute(select(MeasurementType).limit(1)) if result.scalar_one_or_none(): print("Measurement types already seeded, skipping.") else: for name, desc, unit, instructions in MEASUREMENT_TYPES: session.add(MeasurementType(name=name, description=desc, unit=unit, instructions=instructions)) print(f"Seeded {len(MEASUREMENT_TYPES)} measurement types.") await session.commit() if __name__ == "__main__": asyncio.run(seed())