Skip to content

Add exercise persistence schema - #55

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

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

Conversation

@rd-code-23

Copy link
Copy Markdown
Owner

Problem

Routine building needs a persistent exercise catalog that can represent both globally available built-in exercises and custom exercises owned by a registered user.

What changed

  • Added the Drizzle exercises table schema.
  • Exported the table from the complete database schema index.
  • Generated migration 0002_illegal_captain_flint.sql.
  • Added the generated Drizzle snapshot and journal entry.
  • Added concise field comments explaining each column's product responsibility.

Table design

The table contains:

  • id: generated UUID primary key
  • owner_user_id: nullable foreign key to users.id
  • name: required exercise name
  • description: optional instructions or explanation
  • created_at and updated_at: timezone-aware timestamps with defaults

Ownership is represented intentionally:

  • owner_user_id IS NULL means the exercise is built into GoForLift.
  • A user ID means the exercise is a custom exercise owned by that user.

The foreign key uses PostgreSQL's default NO ACTION deletion behavior. Deleting a user therefore cannot silently cascade-delete exercise records. Account and exercise deletion behavior can be finalized deliberately when those operations are implemented.

An index on owner_user_id supports looking up a user's custom exercises and separating them from built-in catalog entries. No speculative name uniqueness rule or additional indexes were added because those requirements are not yet established.

Scope

This PR implements only #54.

Out of scope:

  • built-in exercise seed data
  • exercise CRUD endpoints
  • routine tables
  • routine UI
  • guest persistence
  • workout history tables

Migration verification

After generating the migration, Drizzle detected three tables and reported the expected exercises shape: six columns, one index, and one foreign key. A second generation reported No schema changes, nothing to migrate, confirming the schema and metadata are consistent.

Verification

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

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

Closes #54

@rd-code-23
rd-code-23 merged commit d39705d 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 exercise persistence schema

1 participant