Skip to content

Add routine exercise configuration table - #59

Merged
rd-code-23 merged 1 commit into
mainfrom
feature/routine-exercises-schema
Aug 24, 2026
Merged

rd-code-23 merged 1 commit into
mainfrom
feature/routine-exercises-schema

Conversation

@rd-code-23

Copy link
Copy Markdown
Owner

Problem

A routine needs ordered exercise configuration before it can represent what a user plans to perform. The exercise catalog and core routines table exist, but there is not yet a relationship storing sets, reps, weight, rest, or exercise order.

What changed

  • Added the Drizzle routine_exercises table.
  • Exported it from the complete database schema index.
  • Generated migration 0004_huge_veda.sql and its Drizzle metadata.
  • Finalized planned and historical weight storage as NUMERIC(8,2) in docs/database.md.
  • Added concise field comments and explicit foreign-key deletion behavior.

Table design

Each record connects one exercise to one routine and stores:

  • zero-based exercise position
  • planned number of sets
  • target reps per set
  • one planned weight for all sets in the MVP
  • lb or kg weight unit
  • rest between sets
  • rest after the exercise
  • optional routine-specific notes
  • created and updated timestamps

Integrity rules

PostgreSQL enforces:

  • unique (routine_id, position) values
  • non-negative positions
  • positive sets and target reps
  • non-negative planned weight
  • weight units limited to lb and kg
  • non-negative rest durations

The unique routine-position index also supports loading a routine's ordered exercises. A separate exercise index supports checking whether an exercise is referenced by active routines.

Deleting a routine cascades to its planned exercise configurations because those records have no meaning without the routine. Deleting an exercise uses explicit NO ACTION, preventing removal while an active routine still references it.

Weight representation

NUMERIC(8,2) avoids floating-point rounding behavior, supports common fractional weight increments, and provides substantially more range than the MVP requires. A text column plus a database check is used for units instead of a PostgreSQL enum so future unit changes remain straightforward while the database still rejects unsupported values.

Scope

This PR implements only #58. It does not add per-set planning, schedules, endpoints, UI, guest persistence, or workout history.

Migration verification

Drizzle detected five tables and the expected routine-exercises shape: thirteen columns, two indexes, and two foreign keys. A second generation reported No schema changes, nothing to migrate.

Verification

  • pnpm --filter @goforlift/api typecheck
  • pnpm --filter @goforlift/api test — 48 tests passed
  • pnpm --filter @goforlift/api lint
  • Prettier checks for changed schema, metadata, and documentation
  • git diff --check

The migration is committed but was not applied to a developer's local PostgreSQL database as part of this PR.

Closes #58

@rd-code-23
rd-code-23 merged commit b81fe4c into main Aug 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Routines][Phase 1] Implement routine exercise configuration table

1 participant