refactor
This commit is contained in:
@@ -4,7 +4,7 @@ from sqlalchemy import inspect, select, text
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.db.base import engine
|
||||
from app.db.models import FitnessProfile
|
||||
from app.db.models import FitnessProfile, StepLog
|
||||
from app.fitness.calculators import DEFAULT_NEAT_KCAL, compute_targets, macro_targets
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -173,19 +173,7 @@ def run_fitness_migrations() -> None:
|
||||
)
|
||||
|
||||
if "step_logs" not in inspector.get_table_names():
|
||||
with engine.begin() as conn:
|
||||
conn.execute(
|
||||
text(
|
||||
"CREATE TABLE step_logs ("
|
||||
"id INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||
"logged_at DATETIME DEFAULT CURRENT_TIMESTAMP, "
|
||||
"steps INTEGER DEFAULT 0, "
|
||||
"active_calories FLOAT, "
|
||||
"source VARCHAR(32) DEFAULT 'manual', "
|
||||
"notes TEXT DEFAULT ''"
|
||||
")"
|
||||
)
|
||||
)
|
||||
StepLog.__table__.create(engine, checkfirst=True)
|
||||
|
||||
if "body_metrics" in inspector.get_table_names():
|
||||
_add_column_if_missing(
|
||||
|
||||
Reference in New Issue
Block a user