Repository navigation
Add routine exercise configuration table - #59
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
routine_exercisestable.0004_huge_veda.sqland its Drizzle metadata.NUMERIC(8,2)indocs/database.md.Table design
Each record connects one exercise to one routine and stores:
lborkgweight unitIntegrity rules
PostgreSQL enforces:
(routine_id, position)valueslbandkgThe 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 typecheckpnpm --filter @goforlift/api test— 48 tests passedpnpm --filter @goforlift/api lintgit diff --checkThe migration is committed but was not applied to a developer's local PostgreSQL database as part of this PR.
Closes #58