mirror of
https://github.com/escalante29/healthy-fit.git
synced 2026-03-21 14:08:48 +01:00
Converted frontend codebase from JavaScript to TypeScript, including pages, components, and context. Added new layout and UI kit components. Updated backend user model and schemas to support profile fields (firstname, lastname, age, gender, height, weight, unit_preference) and added endpoints for reading/updating current user. Introduced food log listing endpoint and migration script for user table. Updated dependencies and build configs for TypeScript and Tailwind v4.
33 lines
988 B
Python
33 lines
988 B
Python
from sqlmodel import Session, text
|
|
|
|
from app.db import engine
|
|
|
|
|
|
def migrate():
|
|
print("Starting migration...")
|
|
with Session(engine) as session:
|
|
columns = [
|
|
("firstname", "VARCHAR"),
|
|
("lastname", "VARCHAR"),
|
|
("age", "INTEGER"),
|
|
("gender", "VARCHAR"),
|
|
("height", "FLOAT"),
|
|
("weight", "FLOAT"),
|
|
("unit_preference", "VARCHAR DEFAULT 'metric'"),
|
|
]
|
|
|
|
for col, type_ in columns:
|
|
try:
|
|
print(f"Adding {col}...")
|
|
# Using "user" with quotes to avoid reserved keyword issues, though SQLModel usually handles it
|
|
session.exec(text(f'ALTER TABLE "user" ADD COLUMN IF NOT EXISTS {col} {type_}'))
|
|
session.commit()
|
|
print(f"Added {col}")
|
|
except Exception as e:
|
|
print(f"Error adding {col}: {e}")
|
|
session.rollback()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
migrate()
|