Session 56: Drop the strength schema #233

Closed
opened 2026-11-08 19:56:01 +00:00 by chris-kreidl · 2 comments
chris-kreidl commented 2026-11-08 19:56:01 +00:00 (Migrated from github.com)

56 · Cycling only: drop the strength schema

Phase: Cycling only 2/2 (owner request 2026-11-08, #231) · Branch: session/56-drop-strength-schema · Depends on: 55, merged and deployed

Session 55 stopped every read and write of strength data. This session removes what's left in the database: the tables, columns and enum values. It's a separate PR because production runs the previous build on the new schema during a deploy and after a rollback, so a column can only go once the build before it no longer uses it (CLAUDE.md → Migrations).

Read first

  • Session 55's PR and its docs/decisions.md entry (how the active plans lost their strength sessions)
  • prisma/schema.prisma, prisma/migrations/ (including exercise_fk_deferred and strength_prescription, which add raw-SQL constraints), scripts/check-migrations.ts, and an existing BREAKING.md for the format
  • prisma/seed* (the exercise library seed)

Goal

  1. Check first. On a bun run db:pull copy: count SessionLog, LoggedSet, custom Exercise rows and strength PlannedSession rows in versions after 55's step. Record the counts in docs/history.md. If production has any logged strength rows (none on 2026-11-08), stop and ask the owner before dropping them. If the account JSON export should keep them, write it down there.
  2. Old plan versions. Past PlanVersions still hold strength PlannedSession rows and their PlannedExercise rows (about 250 on 2026-11-08). Dropping the tables means deleting them, which breaks "plans are append-only" for those versions. Owner decision, open: delete them in the migration (old versions then show rides only), or keep SessionKind.strength and a minimal record so old versions stay exactly as they were. Read this issue's comments for the answer; if there isn't one, ask before writing the migration. Record the outcome in docs/decisions.md.
  3. Drop. LoggedSet, SessionLog, PlannedExercise, Exercise and its exclusion relation, AthleteProfile.strengthPerWeek, PlannedSession's strength-only fields, DailyLoad.strengthTssEq, and the enums ExercisePattern, DoseType, Equipment. Remove the enum values SessionKind.strength, PlanTrigger.strength_logged and AiPurpose.normalise once no row uses them. Rewrite or delete old ReplanTrigger and AiCall rows that use them, and say which in the migration. Remove the exercise seed.
  4. BREAKING.md beside the migration names session 55's PR. scripts/check-migrations.ts passes.
  5. Leftovers. Remove the tolerance code 55 kept for old versions with strength sessions, and stored strength rule overrides (rewrite ruleOverrides without them).

Rules

  • The migration runs on production data in Vercel's build. Test it on a db:pull copy and on the preview database (vercel deploy --target preview --yes) before the PR.
  • Session 55's build must keep working on this schema until the deploy finishes. It doesn't read these tables, so dropping them is safe. Confirm that by running 55's commit against the migrated copy.

Tests

  • The migration on a copy: counts before and after, the owner's plan and history open, and load numbers unchanged.
  • Unit, typecheck, lint, format, audit and e2e pass. CI's migration check passes.

Out of scope

Anything beyond removing strength. File follow-ups as issues.

Done when

grep -rli 'strength\|exercise' prisma src finds only the 55 note in the requirements and history, production's schema has no strength objects, and every check passes. Close #231. Finish with the end-of-session ritual in CLAUDE.md.

# 56 · Cycling only: drop the strength schema **Phase:** Cycling only 2/2 (owner request 2026-11-08, #231) · **Branch:** `session/56-drop-strength-schema` · **Depends on:** 55, merged and deployed Session 55 stopped every read and write of strength data. This session removes what's left in the database: the tables, columns and enum values. It's a separate PR because production runs the previous build on the new schema during a deploy and after a rollback, so a column can only go once the build before it no longer uses it (`CLAUDE.md` → Migrations). ## Read first - Session 55's PR and its `docs/decisions.md` entry (how the active plans lost their strength sessions) - `prisma/schema.prisma`, `prisma/migrations/` (including `exercise_fk_deferred` and `strength_prescription`, which add raw-SQL constraints), `scripts/check-migrations.ts`, and an existing `BREAKING.md` for the format - `prisma/seed*` (the exercise library seed) ## Goal 1. **Check first.** On a `bun run db:pull` copy: count `SessionLog`, `LoggedSet`, custom `Exercise` rows and strength `PlannedSession` rows in versions after 55's step. Record the counts in `docs/history.md`. If production has any logged strength rows (none on 2026-11-08), stop and ask the owner before dropping them. If the account JSON export should keep them, write it down there. 2. **Old plan versions.** Past `PlanVersion`s still hold strength `PlannedSession` rows and their `PlannedExercise` rows (about 250 on 2026-11-08). Dropping the tables means deleting them, which breaks "plans are append-only" for those versions. **Owner decision, open:** delete them in the migration (old versions then show rides only), or keep `SessionKind.strength` and a minimal record so old versions stay exactly as they were. Read this issue's comments for the answer; if there isn't one, ask before writing the migration. Record the outcome in `docs/decisions.md`. 3. **Drop.** `LoggedSet`, `SessionLog`, `PlannedExercise`, `Exercise` and its exclusion relation, `AthleteProfile.strengthPerWeek`, `PlannedSession`'s strength-only fields, `DailyLoad.strengthTssEq`, and the enums `ExercisePattern`, `DoseType`, `Equipment`. Remove the enum values `SessionKind.strength`, `PlanTrigger.strength_logged` and `AiPurpose.normalise` once no row uses them. Rewrite or delete old `ReplanTrigger` and `AiCall` rows that use them, and say which in the migration. Remove the exercise seed. 4. **BREAKING.md** beside the migration names session 55's PR. `scripts/check-migrations.ts` passes. 5. **Leftovers.** Remove the tolerance code 55 kept for old versions with strength sessions, and stored strength rule overrides (rewrite `ruleOverrides` without them). ## Rules - The migration runs on production data in Vercel's build. Test it on a `db:pull` copy and on the preview database (`vercel deploy --target preview --yes`) before the PR. - Session 55's build must keep working on this schema until the deploy finishes. It doesn't read these tables, so dropping them is safe. Confirm that by running 55's commit against the migrated copy. ## Tests - The migration on a copy: counts before and after, the owner's plan and history open, and load numbers unchanged. - Unit, typecheck, lint, format, audit and e2e pass. CI's migration check passes. ## Out of scope Anything beyond removing strength. File follow-ups as issues. ## Done when `grep -rli 'strength\|exercise' prisma src` finds only the 55 note in the requirements and history, production's schema has no strength objects, and every check passes. Close #231. Finish with the end-of-session ritual in `CLAUDE.md`.
chris-kreidl commented 2026-11-09 00:27:18 +00:00 (Migrated from github.com)

From #241 (session 55): also remove scripts/remove-strength-sessions.ts, src/server/strength-removal.ts (+ test) and its step in build:vercel, plus the session-55 compatibility code that reads old strength data (grep session 55: StoredPlanTrigger, withoutRetired, the strength kind in HistoryKey and feedback/schema.ts, the strength_logged mapping in claimRun, the normalise label in the Developer panel).

From #241 (session 55): also remove `scripts/remove-strength-sessions.ts`, `src/server/strength-removal.ts` (+ test) and its step in `build:vercel`, plus the session-55 compatibility code that reads old strength data (grep `session 55`: `StoredPlanTrigger`, `withoutRetired`, the `strength` kind in `HistoryKey` and `feedback/schema.ts`, the `strength_logged` mapping in `claimRun`, the `normalise` label in the Developer panel).
chris-kreidl commented 2026-11-09 00:49:25 +00:00 (Migrated from github.com)

From the 92 review of #241:

  • Clear leftover strength sessions before dropping the enum value. scripts/remove-strength-sessions.ts runs at the end of build:vercel, while the old build still serves. A re-plan or generation on the old build in that window can add strength sessions again. Each later deploy removes them, but this session deletes that step. So before removing strength from SessionKind, delete or handle any remaining PlannedSession rows with kind strength (and their PlannedExercise rows) in the migration.
  • The account JSON export stopped writing strength logs in 55, while the rows stay until this session drops them. Production has none, so nothing to do beyond dropping them.
From the 92 review of #241: - **Clear leftover strength sessions before dropping the enum value.** `scripts/remove-strength-sessions.ts` runs at the end of `build:vercel`, while the old build still serves. A re-plan or generation on the old build in that window can add strength sessions again. Each later deploy removes them, but this session deletes that step. So before removing `strength` from `SessionKind`, delete or handle any remaining `PlannedSession` rows with kind `strength` (and their `PlannedExercise` rows) in the migration. - The account JSON export stopped writing strength logs in 55, while the rows stay until this session drops them. Production has none, so nothing to do beyond dropping them.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ckreidl/trainer#233
No description provided.