This is the initial push of the outline of the life dashboard

This commit is contained in:
YOUNG
2026-03-09 12:52:48 -05:00
parent bf1e4e754f
commit 7596a5f382
47 changed files with 6522 additions and 3 deletions

45
backend/alembic/env.py Normal file
View File

@@ -0,0 +1,45 @@
import os
from logging.config import fileConfig
from alembic import context
from sqlalchemy import engine_from_config, pool
from app.database import Base
from app.models import * # noqa: F401,F403 — ensure all models are registered
config = context.config
if config.config_file_name is not None:
fileConfig(config.config_file_name)
target_metadata = Base.metadata
# Override URL from environment if available
url = os.environ.get("DATABASE_URL")
if url:
config.set_main_option("sqlalchemy.url", url)
def run_migrations_offline() -> None:
url = config.get_main_option("sqlalchemy.url")
context.configure(url=url, target_metadata=target_metadata, literal_binds=True)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online() -> None:
connectable = engine_from_config(
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(connection=connection, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

View File

@@ -0,0 +1,25 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision: str = ${repr(up_revision)}
down_revision: Union[str, None] = ${repr(down_revision)}
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
def upgrade() -> None:
${upgrades if upgrades else "pass"}
def downgrade() -> None:
${downgrades if downgrades else "pass"}

View File

@@ -0,0 +1,106 @@
"""Initial schema
Revision ID: 001
Revises:
Create Date: 2026-03-09
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
revision: str = "001"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"weight_entries",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("date", sa.Date, unique=True, nullable=False),
sa.Column("weight_lbs", sa.Numeric(5, 1), nullable=False),
sa.Column("body_fat_pct", sa.Numeric(4, 1), nullable=True),
sa.Column("notes", sa.Text, nullable=True),
sa.Column(
"created_at",
sa.DateTime,
server_default=sa.func.now(),
nullable=False,
),
)
op.create_table(
"exercises",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("name", sa.Text, unique=True, nullable=False),
sa.Column("category", sa.Text, nullable=False),
)
op.create_table(
"workouts",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("date", sa.Date, nullable=False),
sa.Column("name", sa.Text, nullable=True),
sa.Column("notes", sa.Text, nullable=True),
sa.Column(
"created_at",
sa.DateTime,
server_default=sa.func.now(),
nullable=False,
),
)
op.create_table(
"workout_sets",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column(
"workout_id",
sa.Integer,
sa.ForeignKey("workouts.id", ondelete="CASCADE"),
nullable=False,
),
sa.Column(
"exercise_id",
sa.Integer,
sa.ForeignKey("exercises.id"),
nullable=False,
),
sa.Column("set_number", sa.Integer, nullable=False),
sa.Column("reps", sa.Integer, nullable=True),
sa.Column("weight_lbs", sa.Numeric(6, 1), nullable=True),
sa.Column("duration_min", sa.Numeric(5, 1), nullable=True),
)
op.create_table(
"finance_transactions",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("date", sa.Date, nullable=False),
sa.Column("amount", sa.Numeric(12, 2), nullable=False),
sa.Column("category", sa.Text, nullable=False),
sa.Column("description", sa.Text, nullable=True),
sa.Column(
"created_at",
sa.DateTime,
server_default=sa.func.now(),
nullable=False,
),
)
op.create_table(
"finance_snapshots",
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("date", sa.Date, unique=True, nullable=False),
sa.Column("net_worth", sa.Numeric(14, 2), nullable=False),
sa.Column("notes", sa.Text, nullable=True),
)
def downgrade() -> None:
op.drop_table("finance_snapshots")
op.drop_table("finance_transactions")
op.drop_table("workout_sets")
op.drop_table("workouts")
op.drop_table("exercises")
op.drop_table("weight_entries")